@metoceanapi/wxtiles-leaflet 2.0.6 → 2.0.7

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +13 -18
  3. package/dist/es/controls/WxStyleEditorControl.d.ts +1 -1
  4. package/dist/es/controls/WxTimeControl .d.ts +2 -2
  5. package/dist/es/index.d.ts +6 -6
  6. package/dist/es/index.js +6 -1
  7. package/dist/es/utils/wxtools.d.ts +64 -44
  8. package/dist/es/wxAPI/WxDataSetManager.d.ts +7 -1
  9. package/dist/es/wxlayer/WxImplementation.d.ts +3 -3
  10. package/dist/es/wxlayer/loadertools.d.ts +1 -1
  11. package/dist/es/wxlayer/wxlayer.d.ts +5 -7
  12. package/dist/es/wxsource/wxsource.d.ts +2 -2
  13. package/dist/es/wxsource/wxsourcetypes.d.ts +3 -0
  14. package/dist/web/index.js +6 -1
  15. package/docs/docs/assets/search.js +1 -1
  16. package/docs/docs/classes/FrameworkParentClass.html +21 -9
  17. package/docs/docs/classes/Loader.html +7 -7
  18. package/docs/docs/classes/Painter.html +6 -6
  19. package/docs/docs/classes/QTree.html +6 -6
  20. package/docs/docs/classes/RawCLUT.html +7 -7
  21. package/docs/docs/classes/WxAPI.html +18 -18
  22. package/docs/docs/classes/WxDataSetManager.html +37 -20
  23. package/docs/docs/classes/WxLayer.html +25 -25
  24. package/docs/docs/classes/WxLayerBaseImplementation.html +33 -20
  25. package/docs/docs/classes/WxTileSource.html +40 -22
  26. package/docs/docs/enums/TileType.html +4 -4
  27. package/docs/docs/functions/WXLOG.html +4 -3
  28. package/docs/docs/functions/WxCreateLegend.html +2 -1
  29. package/docs/docs/functions/WxGetColorSchemes.html +2 -1
  30. package/docs/docs/functions/WxGetColorStyles.html +2 -1
  31. package/docs/docs/functions/WxTilesLogging.html +4 -3
  32. package/docs/docs/index.html +10 -8
  33. package/docs/docs/interfaces/ColorStylesIncomplete.html +2 -1
  34. package/docs/docs/interfaces/Converter.html +2 -2
  35. package/docs/docs/interfaces/DataIntegral.html +7 -7
  36. package/docs/docs/interfaces/DataPicture.html +5 -5
  37. package/docs/docs/interfaces/FrameworkOptions.html +20 -63
  38. package/docs/docs/interfaces/IntegralPare.html +3 -3
  39. package/docs/docs/interfaces/SLinePoint.html +3 -3
  40. package/docs/docs/interfaces/Tree.html +2 -2
  41. package/docs/docs/interfaces/WxAPIOptions.html +10 -10
  42. package/docs/docs/interfaces/WxAllBoundariesMeta.html +4 -4
  43. package/docs/docs/interfaces/WxBoundaryMeta.html +5 -5
  44. package/docs/docs/interfaces/WxColorSchemes.html +2 -1
  45. package/docs/docs/interfaces/WxColorStyleStrict.html +80 -60
  46. package/docs/docs/interfaces/WxColorStyleWeak.html +80 -60
  47. package/docs/docs/interfaces/WxColorStylesStrict.html +2 -2
  48. package/docs/docs/interfaces/WxColorStylesWeakMixed.html +2 -1
  49. package/docs/docs/interfaces/WxData.html +3 -3
  50. package/docs/docs/interfaces/WxDataSetManagerOptions.html +6 -6
  51. package/docs/docs/interfaces/WxDataSetsMetasJSON.html +2 -2
  52. package/docs/docs/interfaces/WxDatasetMeta.html +9 -9
  53. package/docs/docs/interfaces/WxDatasetShortMeta.html +4 -4
  54. package/docs/docs/interfaces/WxLayerAPI.html +19 -19
  55. package/docs/docs/interfaces/WxLayerBaseAPI.html +15 -15
  56. package/docs/docs/interfaces/WxLayerOptions.html +17 -10
  57. package/docs/docs/interfaces/WxLegend.html +7 -7
  58. package/docs/docs/interfaces/WxLngLat.html +3 -3
  59. package/docs/docs/interfaces/WxRasterData.html +5 -5
  60. package/docs/docs/interfaces/WxRequestInit.html +2 -2
  61. package/docs/docs/interfaces/WxSourceLayerOptions.html +109 -0
  62. package/docs/docs/interfaces/WxTick.html +5 -5
  63. package/docs/docs/interfaces/WxTileInfo.html +9 -9
  64. package/docs/docs/interfaces/WxTilesLibOptions.html +4 -4
  65. package/docs/docs/interfaces/WxUnits.html +2 -1
  66. package/docs/docs/interfaces/WxVariableMeta.html +6 -6
  67. package/docs/docs/interfaces/WxVariablesMetas.html +2 -1
  68. package/docs/docs/interfaces/XYZ.html +4 -4
  69. package/docs/docs/modules.html +2 -0
  70. package/docs/docs/types/DataIntegrals.html +2 -1
  71. package/docs/docs/types/DataPictures.html +2 -1
  72. package/docs/docs/types/SLine.html +2 -1
  73. package/docs/docs/types/SubTrees.html +2 -1
  74. package/docs/docs/types/SubTreesN.html +2 -1
  75. package/docs/docs/types/TreeN.html +2 -1
  76. package/docs/docs/types/UriLoaderPromiseFunc.html +2 -1
  77. package/docs/docs/types/WxDate.html +2 -1
  78. package/docs/docs/types/WxURIs.html +2 -1
  79. package/docs/docs/types/WxUnitTuple.html +2 -1
  80. package/docs/docs/types/WxVars.html +2 -1
  81. package/docs/script/script.js +8 -3
  82. package/package.json +2 -2
  83. package/src_example/index.ts +111 -54
package/CHANGELOG.md CHANGED
@@ -9,6 +9,8 @@ Write your changes below this section. `npm version [major|minor|patch]` will au
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [2.0.7] - 2022-11-30
13
+
12
14
  ## [2.0.6] - 2022-11-27
13
15
 
14
16
  ## [2.0.5] - 2022-11-24
package/README.md CHANGED
@@ -7,15 +7,17 @@ There are three main parts of the project:
7
7
  2. [WxTiles-mbox source code](https://github.com/metoceanapi/wxtiles-mbox), npm [@metoceanapi/wxtiles-mbox](https://www.npmjs.com/package/@metoceanapi/wxtiles-mbox) - a JS API providing work with metadata, dataset manager and an implementation of a Custom MapBox-gl-gs Layer for visualizing the tiles using [Mapbox-gl-gs](https://www.mapbox.com/).
8
8
  3. [WxTiles-leaflet source code](https://github.com/metoceanapi/wxtiles-leaflet), npm [@metoceanapi/wxtiles-leaflet](https://www.npmjs.com/package/@metoceanapi/wxtiles-leaflet) - a JS API providing work with metadata, dataset manager and an implementation of a Custom Leaflet Layer for visualizing the tiles using [Leaflet](https://leafletjs.com/).
9
9
 
10
+ ## API
11
+
12
+ APIs for Leaflet and Mapbox-gl-gs are similar in many ways. The difference is in framework-specific implementations of the Custom Source/Layer.
13
+
14
+ Usage and API documentation is mainly equal for both frameworks.
15
+
10
16
  ## DOCS
11
17
 
12
18
  - Mapbox-gl: https://metoceanapi.github.io/wxtiles-mbox/docs/
13
19
  - Leaflet: https://metoceanapi.github.io/wxtiles-leaflet/docs/
14
20
 
15
- ## API
16
-
17
- APIs for Leaflet and Mapbox-gl-gs are similar, but they have different implementations of the Custom Source/Layer.
18
-
19
21
  ## Examples
20
22
 
21
23
  ### MapBox-gl-js
@@ -107,19 +109,19 @@ await wxsource.setTimeStep(new Date('2020-01-01T00:00:00Z')); // Date object
107
109
  ### Update the style
108
110
 
109
111
  ```ts
110
- await wxsource.updateCurrentStyleObject({ units: 'm/s', levels: undefined }); // levels: undefined - to recalculate levels
112
+ await wxsource.updateCurrentStyleObject({ units: 'm/s', levels: undefined }); // set levels to undefined - to automatically calculate the levels from the dataset
111
113
  ```
112
114
 
113
115
  ### Preload the time steps
114
116
 
115
117
  ```ts
116
- // load to the cache the time steps 10 but not render it
118
+ // load the time step 10 to the cache but do not not render it
117
119
  const prom = wxsource.preloadTime(10);
118
120
  // do stuff asyncronously
119
121
  // ...
120
122
  await prom; // wait for the time step to finish loading
121
123
  // now set the time step to 10
122
- await wxsource.setTime(10); // will be rendered from the cache
124
+ await wxsource.setTime(10); // will be fast rendered from the cache
123
125
  ```
124
126
 
125
127
  ### Abort loading
@@ -155,17 +157,10 @@ map.on('mousemove', (e) => {
155
157
  ### animated blur effect
156
158
 
157
159
  ```ts
158
- let b = 0;
159
- let db = 1;
160
- const nextAnim = async () => {
161
- if (!wxsource) return;
162
- await wxsource.updateCurrentStyleObject({ blurRadius: b }); // await always !!
163
-
164
- b += db;
165
- if (b > 16 || b < 0) db = -db;
166
- setTimeout(nextAnim, 1);
167
- };
168
- setTimeout(nextAnim, 2000);
160
+ (async function step(n: number = 0) {
161
+ await wxsource.updateCurrentStyleObject({ isolineText: false, blurRadius: ~~(10 * Math.sin(n / 500) + 10) }); // await always !!
162
+ requestAnimationFrame(step);
163
+ })();
169
164
  ```
170
165
 
171
166
  ### more interactive - additional level and a bit of the red transparentness around the level made from current mouse position
@@ -1,7 +1,7 @@
1
1
  import { WxColorStyleStrict } from '../index';
2
2
  import { WxColorStyleWeak } from '../index';
3
3
  export declare class WxStyleEditorControl {
4
- onchange?: (style: WxColorStyleWeak) => Promise<void>;
4
+ onchange?: (style: WxColorStyleWeak, nonnative?: boolean) => Promise<void>;
5
5
  editorTextAreaEl: HTMLTextAreaElement;
6
6
  editorDivEl: HTMLDivElement;
7
7
  parentInput: HTMLInputElement;
@@ -1,6 +1,6 @@
1
1
  import { WxTileSource } from '../index';
2
2
  export declare class WxTimeControl {
3
- private readonly delay;
3
+ readonly delay: number;
4
4
  private wxsource?;
5
5
  private readonly _div;
6
6
  private readonly button;
@@ -8,7 +8,7 @@ export declare class WxTimeControl {
8
8
  onchange: (time: string) => void;
9
9
  constructor(delay: number, wxsource?: WxTileSource | undefined);
10
10
  setTimes(times: string[]): void;
11
- updateSource(wxsource: WxTileSource): void;
11
+ updateSource(wxsource?: WxTileSource): void;
12
12
  onAdd(): HTMLDivElement;
13
13
  onRemove(): void;
14
14
  extender(): {
@@ -20,16 +20,16 @@
20
20
  */
21
21
  export { WxAPI } from './wxAPI/wxAPI';
22
22
  export type { WxAPIOptions, WxDatasetMeta, WxDatasetShortMeta, WxDataSetsMetasJSON, WxVariableMeta, WxVariablesMetas, WxBoundaryMeta, WxAllBoundariesMeta, } from './wxAPI/wxAPI';
23
- export { WxDataSetManager, type WxDataSetManagerOptions } from './wxAPI/WxDataSetManager';
23
+ export { WxDataSetManager, type WxDataSetManagerOptions, type WxSourceLayerOptions } from './wxAPI/WxDataSetManager';
24
24
  export { WxTileSource } from './wxsource/wxsource';
25
25
  export { type FrameworkOptions, FrameworkParentClass } from './wxsource/wxsourcetypes';
26
26
  export type { WxLayerOptions, WxDate, WxRequestInit, WxTileInfo, WxVars, WxLngLat, WxURIs } from './wxlayer/wxlayer';
27
27
  export { WxLayer } from './wxlayer/wxlayer';
28
28
  export type { WxLayerBaseAPI, WxLayerBaseImplementation, WxLayerAPI } from './wxlayer/WxImplementation';
29
- export { WxCreateLegend, type WxLegend, type WxTick } from './utils/RawCLUT';
29
+ export { WxCreateLegend, RawCLUT, type WxLegend, type WxTick } from './utils/RawCLUT';
30
30
  export { WxGetColorStyles, WxGetColorSchemes, WxTilesLogging, WXLOG } from './utils/wxtools';
31
31
  export type { XYZ, WxUnits, WxUnitTuple, WxColorSchemes, WxColorStyleWeak, WxColorStyleStrict, WxColorStylesStrict, WxColorStylesWeakMixed, WxTilesLibOptions, ColorStylesIncomplete, Converter, IntegralPare, DataIntegral, DataIntegrals, DataPicture, DataPictures, UriLoaderPromiseFunc, } from './utils/wxtools';
32
- export { Painter, WxRasterData } from './wxlayer/painter';
33
- export { Loader, WxData, SLine, SLinePoint } from './wxlayer/loader';
34
- export { type TileType, QTree, Tree, SubTrees, SubTreesN, TreeN } from './utils/qtree';
35
- export { RawCLUT } from './utils/RawCLUT';
32
+ export { Painter, type WxRasterData } from './wxlayer/painter';
33
+ export { Loader, type WxData, type SLine, type SLinePoint } from './wxlayer/loader';
34
+ export { QTree } from './utils/qtree';
35
+ export type { TileType, Tree, SubTrees, SubTreesN, TreeN } from './utils/qtree';
package/dist/es/index.js CHANGED
@@ -1 +1,6 @@
1
- var _e=Object.create;var K=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,oe=Object.getOwnPropertySymbols,Ne=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var ie=(a,e,t)=>e in a?K(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,X=(a,e)=>{for(var t in e||(e={}))le.call(e,t)&&ie(a,t,e[t]);if(oe)for(var t of oe(e))Ze.call(e,t)&&ie(a,t,e[t]);return a};var Fe=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ve=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Oe(e))!le.call(a,n)&&n!==t&&K(a,n,{get:()=>e[n],enumerable:!(r=Ue(e,n))||r.enumerable});return a};var Be=(a,e,t)=>(t=a!=null?_e(Ne(a)):{},Ve(e||!a||!a.__esModule?K(t,"default",{value:a,enumerable:!0}):t,a));var y=(a,e,t)=>new Promise((r,n)=>{var s=c=>{try{i(t.next(c))}catch(l){n(l)}},o=c=>{try{i(t.throw(c))}catch(l){n(l)}},i=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,o);i((t=t.apply(a,e)).next())});var Re=Fe((rr,ke)=>{ke.exports=window.L});var ce={comment1:["'degC': ['K', 1, 273.15] -> degC = K * 1 + 273.15",0],comment2:["'hPa': ['Pa', 1000]' -> hPa = Pa * 1000 + 0 (0 - could be ommited)",0],K:["K",1],kelvin:["K",1],F:["K",.5555555555,255.372222222],C:["K",1,273.15],degC:["K",1,273.15],"kg/m^2/s":["kg/m^2/s",1],"Kg/m^2/s":["kg/m^2/s",1],"Kg m**-2 s**-1":["kg/m^2/s",1],"Kg m^-2 s^-1":["kg/m^2/s",1],"Kg m^{-2} s^-1":["kg/m^2/s",1],"mm/h":["kg/m^2/s",.00027777777],"mm/hr":["kg/m^2/s",.00027777777],"W/m^2":["W/m^2",1],"W m^-2":["W/m^2",1],"W m^{-2}":["W/m^2",1],"W/m**2":["W/m^2",1],"W m**-2":["W/m^2",1],"m/s":["m/s",1],"m s**-1":["m/s",1],"m s^-1":["m/s",1],"m.s^{-1}":["m/s",1],knot:["m/s",.514444],knots:["m/s",.514444],"km/h":["m/s",.27777777777],"km h^-1":["m/s",.27777777777],"km h**-1":["m/s",.27777777777],mph:["m/s",.44704],"miles/h":["m/s",.44704],s:["s",1],sec:["s",1],h:["s",3600],min:["s",60],m:["m",1],cm:["m",.01],km:["m",1e3],mile:["m",1609.344],miles:["m",1609.344],inch:["m",.0254],Pa:["Pa",1],hPa:["Pa",100],degree:["degree",1],radian:["degree",57.3],"mg/m^3":["mg/m^3",1],"mg m^-3":["mg/m^3",1],"mg.m^-3":["mg/m^3",1],"%":["%",1],"(0 - 1)":["%",100]};var ue={none:["#00000000","#00000000"],divergingbluered:["#2166acff","#92c5deff","#f7f7f7ff","#f4a582ff","#b2182bff"],rainbow:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbowzerro:["#ff000000","#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff"],rainbow2:["#ff0000ff","#ffff00ff","#00ff00ff","#00ffffff","#0000ffff","#ff00ffff","#ff0000ff"],bluebird:["#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bluebirdzerro:["#0000ff00","#0000ffff","#ff00ffff","#00ffffff","#9000ffff","#9090ffff"],bw:["#000000ff","#ffffffff"],wb:["#ffffffff","#000000ff"],redish:["#ff00ffff","#ff0000ff","#ffff00ff"],greenish:["#ffff00ff","#00ff00ff","#00ffffff"],blueish:["#ff00ffff","#0000ffff","#00ffffff"],hspastel:["#AC6EA4FF","#8E92BDFF","#ACD4DEFF","#E9DC8EFF","#E7A97DFF","#E59074FF","#BE7E68FF","#A88F86FF"]};var $={base:{parent:void 0,name:"base",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"divergingbluered",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"},custom:{parent:void 0,name:"custom",fill:"gradient",isolineColor:"inverted",isolineText:!0,vectorType:"arrows",vectorColor:"inverted",vectorFactor:1,streamLineColor:"#777",streamLineSpeedFactor:1,streamLineStatic:!1,showBelowMin:!0,showAboveMax:!0,colorScheme:"rainbow",colors:void 0,colorMap:void 0,levels:void 0,blurRadius:0,addDegrees:0,units:"",extraUnits:void 0,mask:"none"}};var me,fe,de;function xe({colorStyles:a={},units:e={},colorSchemes:t={}}={}){h("WxTile lib setup: start"),me=Object.assign({},ce,e),fe=Object.assign({},t,ue);let r=Object.assign({},a,$);de=Xe(r),h("WxTile lib setup: styles unrolled");try{y(this,null,function*(){yield document.fonts.load("32px barbs"),yield document.fonts.load("32px arrows")})}catch(n){h("WxTile lib setup: fonts not loaded")}h("WxTile lib setup is done.")}function A(){return de}function H(){return fe}function E(a,e,t){h("makeConverter: From=",a," To=",e);let r=m=>m;if(r.trivial=!0,a===e)return h("Trivial converter"),r;let n=Object.assign({},me,t),s=n[a],o=n[e];if(!s||!o)return h("Inconvertible units. Trivial converter"),r;let[i,c,l]=s,[u,f,d]=o;if(i!==u||!c||!f)return h("Inconvertible units. Trivial converter"),r;let g=c/f,x=((l||0)-(d||0))/f;return x?m=>g*m+x:m=>g*m}function Xe(a){let e=Object.assign({},$);for(let s in a){let o=a[s];if(Array.isArray(o))for(let i=0;i<o.length;++i)e[s+"["+i+"]"]=Object.assign({},o[i]);else e[s]=Object.assign({},o)}let t=Object.assign({},$.base),r=(s,o)=>{if(o==="base")return t;let i=s[o];if(!i)return t;(!i.parent||!(i.parent in s))&&(i.parent="base");let c=r(s,i.parent);return Object.assign(i,Object.assign({},c,i,{parent:"base"}))},n={base:t};for(let s in e)n[s]=r(e,s);return n}function _(a){let e=new Map;return(t,...r)=>{let n=e.get(t);if(n)return n;let s=a(t,...r);return e.set(t,s),s.catch(o=>{o.name==="AbortError"&&e.delete(t)}),s}}function $e(a,e){return y(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}function I(a,e,t=!0){let r=Object.assign(document.createElement("canvas"),{width:a,height:e,imageSmoothingEnabled:!1}).getContext("2d",{willReadFrequently:t});if(!r)throw new Error("Cannot get canvas context");return r}function Ee(a){let{width:e,height:t}=a,r=I(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function J(a,e){return y(this,null,function*(){return Ee(yield $e(a,e))})}function qe(a){a.data[34]<1&&h("Warning: image is in too old format. Check the version of the Splitter.");let e=new Uint16Array(a.data.buffer),t=new Uint16Array(e.length/2);for(let l=0;l<t.length;l++)t[l]=e[l*2];let r=new Uint8Array(8);for(let l=0;l<8;++l)r[l]=a.data[l*4+2];let n=new DataView(r.buffer),s=n.getFloat32(0,!0),o=n.getFloat32(4,!0),i=(o-s)/65535,c=Ye(t);return{raw:t,dmin:s,dmax:o,dmul:i,integral:c,radius:0}}function Q(a,e){return y(this,null,function*(){return qe(yield J(a,e))})}function Ye(a){let e=new Uint32Array(66564),t=new Uint32Array(258*258);e[0]=a[0],t[0]=a[0]===0?0:1;for(let r=1;r<258;++r)e[r]=a[r]+e[r-1],e[258*r]=a[258*r]+e[258*r-258],t[r]=(a[r]===0?0:1)+t[r-1],t[258*r]=(a[258*r]===0?0:1)+t[258*r-258];for(let r=1,n=259;r<258;++r,++n)for(let s=1;s<258;++s,++n)e[n]=a[n]+e[n-258]+e[n-1]-e[n-258-1],t[n]=(a[n]===0?0:1)+t[n-258]+t[n-1]-t[n-258-1];return{integral:e,integralNZ:t}}function pe(a,e){if(e<0||e===a.radius)return a;a.radius=e;let t=258,{integral:r,integralNZ:n}=a.integral;for(let s=1;s<t;s++)for(let o=1;o<t;o++){if(!a.raw[t*s+o])continue;let i=Math.min(e,o-1,t-1-o),c=Math.min(e,s-1,t-1-s),l=t*(s-c-1)+o,u=t*(s+c)+o,f;if(n){let b=n[l-i-1],W=n[l+i],w=n[u-i-1],T=n[u+i];f=b+T-W-w}else f=(2*i+1)*(2*c+1);let d=r[l-i-1],g=r[l+i],x=r[u-i-1],m=r[u+i],p=d+m-g-x;a.raw[s*t+o]=p/f}return a}function M(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),s=t.toString(16),o=r.toString(16);return n=n.length===2?n:"0"+n,s=s.length===2?s:"0"+s,o=o.length===2?o:"0"+o,"#"+n+s+o}function C(a){if(a[0]==="#"){if(a.length===4)return+("0xff"+a[3]+a[3]+a[2]+a[2]+a[1]+a[1]);if(a.length===7)return+("0xff"+a[5]+a[6]+a[3]+a[4]+a[1]+a[2]);if(a.length===9)return+("0x"+a[7]+a[8]+a[5]+a[6]+a[3]+a[4]+a[1]+a[2])}return h("wrong color format",a),0}function L(a,e){return y(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function ee(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,o=a>>>24,i=e>>0&255,c=e>>8&255,l=e>>16&255,u=e>>>24,f=r+t*(i-r),d=n+t*(c-n),g=s+t*(l-s),x=o+t*(u-o);return f|d<<8|g<<16|x<<24}function ge(a,e,t){let r=[];for(let n=0;n<t;++n)r.push(n*(e-a)/(t-1)+a);return r}var he=!1;function je(a){console.log(a?"Logging on":"Logging off"),he=a}function h(...a){he&&console.log(...a)}function ye(a){return a[0]==="#"&&a.length===4?"#"+a[1]+a[1]+a[2]+a[2]+a[3]+a[3]:a}function q(a,{x:e,y:t,z:r}){return a.replace("{x}",`${e}`).replace("{y}",`${t}`).replace("{z}",`${r}`)}function Y({x:a,y:e,z:t}){return`${t}-${a}-${e}`}var Ge="A".charCodeAt(0);var U=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0}load(e,t){return y(this,null,function*(){try{let r=yield L(e,t);this.qtree=be(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=We(this.qtree)})}check(e){let t=e.z-this.qtreedepth,r=t>=0,n=r?{x:e.x>>t,y:e.y>>t,z:this.qtreedepth}:X({},e);return we(this.qtree,n,r)}};function be(a,e){let t=a.charCodeAt(e.pos)-Ge;e.pos++;let r=[1,2,4,8].map(n=>t&n?be(a,e):null);return{nodes:r.some(n=>n)?r:null}}function We(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(We)):0}function we(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,we(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}var O=class{constructor({datasetName:e,instance:t,instanced:r,meta:n,wxapi:s}){if(!s.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.instance=t,this.meta=n,this.wxapi=s}getValidTime(e=Date()){let t=this.getTimes();if(typeof e=="number"){if(e<=0)return t[0];if(e<t.length)return t[e]}let r=new Date(e).getTime(),n=t.find(s=>new Date(s).getTime()>=r);if(isNaN(r)||!n){let s=t.indexOf(e);return s===-1?t[t.length-1]:t[s]}return n}getTimes(){return this.instanced||this.meta.times}getVariables(){return this.meta.variables}getVariableMeta(e){return this.meta.variablesMeta[e]}getMaxZoom(){return this.meta.maxZoom}getBoundaries180(){var r;let e=(r=this.meta.boundaries)==null?void 0:r.boundaries180;if((e==null?void 0:e.length)!==1)return;let t=e[0];return[t.west,t.south,t.east,t.north]}getBoundaries(){return this.meta.boundaries}createURI(e,t,r="png"){if(!this.checkVariableValid(e))throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);let n=this.getValidTime(t),s=this.instanced?n:this.instance;return`${this.wxapi.dataServerURL+this.datasetName}/${s}/${e}/${n}/{z}/{x}/{y}.${r}`}checkVariableValid(e){return this.getVariableMeta(e)!==void 0}checkCombineVariableIfVector(e){let t=this.getVariableMeta(e);if(!t)throw new Error(`in dataset ${this.datasetName} variable ${e} not found`);return t.vector||[e]}checkDatasetOutdated(){return y(this,null,function*(){return yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return y(this,null,function*(){let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return y(this,null,function*(){try{let e=yield L(this.wxapi.dataServerURL+this.datasetName+"/instances.json",this.wxapi.requestInit);if(e.length===0)throw new Error(`No instances found for dataset ${this.datasetName}`);return e}catch(e){throw new Error(`getting dataset instances failure message: ${e.message} datasetName: ${this.datasetName}`)}})}};var te=class{constructor({dataServerURL:e,maskURL:t="auto",maskChannel:r="R",maskDepth:n=9,qtreeURL:s="auto",requestInit:o,colorStyles:i,units:c,colorSchemes:l}){this.maskURL="auto";this.datasetsMetas={allDatasetsList:[]};this.qtree=new U;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(xe({colorStyles:i,units:c,colorSchemes:l}),this.dataServerURL=e,this.requestInit=o,s=s==="auto"?e+"masks/9+1.seamask.qtree":s,t!=="none"){let u=_(J);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=f=>u(q(t,f),o)}this.maskChannel=r==="R"?0:r==="G"?1:r==="B"?2:r==="A"?3:0,this.maskDepth=n,this.initDone=Promise.all([L(e+"datasetsmeta.json",o),s!=="none"?this.qtree.load(s,o):Promise.resolve()]).then(([u,f])=>{u.allDatasetsList||(u.allDatasetsList=Object.keys(u)),this.datasetsMetas=u})}getDatasetShortMeta(e){if(e!=="allDatasetsList")return this.datasetsMetas[e]}getDatasetInatance(e){var t;return(t=this.getDatasetShortMeta(e))==null?void 0:t.instance}getDatasetVariables(e){return y(this,null,function*(){var t;return yield this.initDone,(t=this.datasetsMetas[e])==null?void 0:t.variables})}createDatasetManager(e){return y(this,null,function*(){yield this.initDone;let t=this.getDatasetShortMeta(e),r=t==null?void 0:t.instance;if(!r)throw new Error("Dataset/instance not found:"+e);let n=t.instanced,s=yield L(this.dataServerURL+e+"/"+r+"/meta.json",this.requestInit);return new O({datasetName:e,instanced:n,instance:r,meta:s,wxapi:this})})}createAllDatasetsManagers(){return y(this,null,function*(){return yield this.initDone,Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return y(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList.filter(t=>{var r,n,s;return(s=(n=(r=this.datasetsMetas[t])==null?void 0:r.variables)==null?void 0:n.includes)==null?void 0:s.call(n,e)})})}getAllDatasetsNames(){return y(this,null,function*(){return yield this.initDone,this.datasetsMetas.allDatasetsList})}};function ze(a,e,t){return a>t?t:a<e?e:a}var N=class{constructor(e,t,[r,n],s){let o=n-r;this.levelIndex=new Uint32Array(65536),this.colorsI=new Uint32Array(65536);let i=[];this.DataToStyle=E(t,e.units,e.extraUnits),this.DataToStyle.trivial&&(e.units=t),s&&(this.DataToKnots=E(t,"knot"));let c=E(e.units,t,e.extraUnits),l=m=>~~(65535*ze((c(m)-r)/(n-r),0,1));if(Array.isArray(e.colorMap)){e.colorMap.sort((m,p)=>m[0]<p[0]?-1:m[0]>p[0]?1:0);for(let[m]of e.colorMap)i.push(l(m))}else{if(e.levels||(e.levels=ge(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((m,p)=>m<p?-1:m>p?1:0),!e.colors){let m=H();e.colorScheme&&e.colorScheme in m?e.colors=m[e.colorScheme]:e.colors=m.wb}for(let m of e.levels)i.push(l(m))}let u=65536,f=De(u,e);this.ticks=f.ticks;let d=f.ticks[0].data,x=f.ticks[f.ticks.length-1].data-d;for(let m=0;m<65536;++m){let p=o*m/65535+r,b=this.DataToStyle(p),W=Math.round((u-1)*(b-d)/x);W<=0?this.colorsI[m]=e.showBelowMin?f.colors[0]:0:W>=u?this.colorsI[m]=e.showAboveMax?f.colors[u-1]:0:this.colorsI[m]=f.colors[W]}this.colorsI[0]=0;for(let m=0;m<i[0];++m)this.levelIndex[m]=0;for(let m=0;m<i.length-1;m++)for(let p=i[m];p<i[m+1]+1;++p)this.levelIndex[p]=m;for(let m=i[i.length-1];m<65536;++m)this.levelIndex[m]=i.length-1}};function Se(a){var t;if(a!==0&&-.1<a&&a<.1)return a.toExponential(2);let e=a.toString();return((t=e.split(".")[1])==null?void 0:t.length)>2?a.toFixed(2):e}function De(a,e){let t={size:a,showBelowMin:e.showBelowMin,showAboveMax:e.showAboveMax,units:e.units,colors:new Uint32Array(a),ticks:[]},{colorMap:r,levels:n,colors:s}=e,o=e.fill!=="solid";if(r){let d=r[0][0],g=r[r.length-1][0]-d;for(let[x,m]of r){let p=~~((x-d)/g*(a-1)),b={data:x,dataString:Se(x),color:m,pos:p};t.ticks.push(b)}for(let x=0;x<r.length-1;x++){let m=t.ticks[x].pos,p=t.ticks[x+1].pos,b=C(r[x][1]),W=o?C(r[x+1][1]):0;for(let w=m;w<p;++w)t.colors[w]=o?ee(b,W,(w-m)/(p-m)):b}return t.colors[a-1]=C(r[r.length-1][1]),t}if(!s||!n)return t;let i=0,c=0,l=-1;for(let d=0;d<a;++d){let g=d*(s.length-1)/a;l!==~~g&&(l=~~g,i=C(s[l]),c=s.length>l+1?C(s[l+1]):i),t.colors[d]=o?ee(i,c,g-l):i}t.colors[a-1]=C(s[s.length-1]);let u=n[0],f=(a-1)/(n[n.length-1]-u);for(let d of n){let g=~~((d-u)*f),x={data:d,dataString:Se(d),color:M(t.colors[g]),pos:g};t.ticks.push(x)}return t}var Ke=2*Math.PI*6378137/256,j=2*Math.PI*6378137/2;function He(a,e){let t=a/j*180,r=e/j*180;return r=180/Math.PI*(2*Math.atan(Math.exp(r*Math.PI/180))-Math.PI/2),[r,t]}function Je(a,e,t){let r=Qe(t),n=a*r-j,s=e*r-j;return[n,s]}function Qe(a){return Ke/Math.pow(2,a)}function re(a,e,t){let[r,n]=He(...Je(a,e,t));return[n,-r]}function Te(a,e){return[a*256,e*256]}function ae(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function et(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=o+i*a,e=o+i*e,t=o+i*t,r=o+i*r;let l=ae(a,e,n),u=ae(t,r,n);return(ae(l,u,s)-o)/i||1}function tt(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 7:return n+s<1?n*(e-a)+s*(t-a)+a:0;case 14:return n+s<1?0:n*(r-t)+s*(r-e)+e+t-r;case 11:return s<n?(1-n)*(a-e)+s*(r-e)+e:0;case 13:return s<n?0:(1-n)*(t-r)+s*(t-a)+a+r-t;case 15:return n+s<1?n*(e-a)+s*(t-a)+a:n*(r-t)+s*(r-e)+e+t-r;default:return 0}}function Me(a,e,t){let r=.9999999/Math.pow(2,t.z),n=t.x*256*r,s=t.y*256*r,{raw:o,dmin:i,dmax:c,dmul:l}=e,u={raw:new Uint16Array(258*258),dmin:i,dmax:c,dmul:l},{raw:f}=u;for(let d=-1,g=0;d<=256;d++){let x=s+d*r,m=Math.floor(x),p=x-m;for(let b=-1;b<=256;b++,g++){let W=n+b*r,w=Math.floor(W),T=W-w,S=w+1+(m+1)*258,D=o[S],v=o[S+1],P=o[S+258],k=o[S+258+1];f[g]=a(D,v,P,k,T,p,i,l)}}return u}function Ce(a,e){if(!e)return a;let t=1/Math.pow(2,e.z),r=e.x*256*t,n=e.y*256*t,{data:s}=a,o=new ImageData(256,256),{data:i}=o;for(let c=0,l=0;c<256;c++){let u=n+c*t,f=Math.floor(u);f===255&&(f=254);let d=u-f;for(let g=0;g<256;g++,l++){let x=r+g*t,m=Math.floor(x);m===255&&(m=254);let p=x-m,b=(m+f*256)*4+0,W=s[b],w=s[b+4],T=s[b+4*256],S=s[b+4*256+4],D=p+d<1?p*(w-W)+d*(T-W)+W:p*(S-T)+d*(S-w)+w+T-S;i[l*4]=D>127?255:0}}return o}function ve(a,e){return e?Me(tt,a,e):a}function Le(a,e){return e?Me(et,a,e):a}function Ie(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let o=t,i=259,c=0;c<256;i+=2,c++)for(let l=0;l<256;l++,i++,o+=4)n===!e[o]&&(s[i]=0);return a}function Pe(a){let[e,t]=Te(a.x,a.y),[r,n]=re(e,t,a.z),[s,o]=re(e+256,t+256,a.z);return{west:r,north:n,east:s,south:o}}function ne(a,e){let t=a.z-e;if(t<=0)return{upCoords:a};let r={x:a.x>>>t,y:a.y>>>t,z:e},n={x:a.x&(1<<t)-1,y:a.y&(1<<t)-1,z:t};return{upCoords:r,subCoords:n}}var Z=class{constructor(e){this.loadDataFunc=_(Q);this.layer=e}load(e,t){return y(this,null,function*(){let r=yield this.cacheLoad(e,this.layer.tilesURIs,t);if(!r)return null;let{rawdata:n,subCoords:s,tileType:o}=r,{units:i}=this.layer.currentMeta,c=i==="degree"?Le:ve,l=f=>c(pe(f,this.layer.style.blurRadius),s),u=n.map(l);return this._vectorMagnitudesPrepare(u),yield this._applyMask(u,e,o,!s&&n.length===1),{data:u,slines:this._createStreamLines(u)}})}cacheLoad(e,t,r){return y(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:o}=ne(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(u=>q(u,s)),c=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(u=>this.loadDataFunc(u,c))),subCoords:o,tileType:n}})}clearCache(){this.loadDataFunc=_(Q)}_applyMask(e,t,r,n){return y(this,null,function*(){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:c,dmax:l,dmul:u}=e[0];e[0]={raw:new Uint16Array(i),dmin:c,dmax:l,dmul:u}}let o;try{let{upCoords:i,subCoords:c}=ne(t,this.layer.wxdatasetManager.wxapi.maskDepth);o=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(i),o=Ce(o,c)}catch(i){s.mask=void 0,h("Can't load Mask. Masking is disabled");return}Ie(e[0],o,this.layer.wxdatasetManager.wxapi.maskChannel,s.mask)}})}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let s=0;s<258*258;++s){if(!r.raw[s]||!n.raw[s])continue;let o=r.dmin+r.dmul*r.raw[s],i=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(i*i+o*o)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;var r="mixed";if(!((t==="land"||t==="sea")&&(r=this.layer.wxdatasetManager.wxapi.qtree.check(e),t===r)))return r}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=Pe(e),n=s=>!(r.west>s.east||s.west>r.east||r.south>s.north||s.south>r.north);if(!t.boundaries180.some(n))return!1}return!0}_createStreamLines(e){if(e.length!==3)return[];let{style:t}=this.layer;if(t.streamLineColor==="none")return[];let r=[],[n,s,o]=e,i=(t.streamLineSpeedFactor||1)/n.dmax,c=t.addDegrees?.017453292519943*t.addDegrees:0,l=t.streamLineGridStep||64,u=t.streamLineSteps||300;for(let f=0;f<=256;f+=l)for(let d=0;d<=256;d+=l){if(!n.raw[1+d+(1+f)*258])continue;let g=[],x=d,m=f,p=-1,b=0,W=0;for(let S=0;S<=u&&x>=0&&x<=256&&m>=0&&m<=256;S++){S%(u/10)||g.push({x:~~x,y:~~m});let D=~~x+1+(~~m+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,P=s.dmin+s.raw[D]*s.dmul,k=o.dmin+o.raw[D]*o.dmul,R=Math.atan2(P,k)+c;b=i*v*Math.sin(R),W=i*v*Math.cos(R)}x+=b,m-=W}let w=d,T=f;p=-1;for(let S=1;S<=u&&w>=0&&w<=256&&T>=0&&T<=256;S++){S%(u/10)||g.unshift({x:~~w,y:~~T});let D=~~w+1+(~~T+1)*258;if(D!==p){if(!n.raw[D])break;p=D;let v=n.dmin+n.raw[D]*n.dmul,P=s.dmin+s.raw[D]*s.dmul,k=o.dmin+o.raw[D]*o.dmul,R=Math.atan2(P,k)+c;b=i*v*Math.sin(R),W=i*v*Math.cos(R)}w-=b,T+=W}g.length>2&&r.push(g)}return r}};var F=class{constructor(e){this.layer=e}paint({data:e,ctxFill:t,ctxText:r,ctxStreamLines:n}){let{layer:s}=this,{units:o}=s.currentMeta,i=new ImageData(256,256),c=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),rt(e.data[0],c,s);let l=at(c,e.data[0],s);t.putImageData(i,0,0),nt(l,r,s),st(e.data,r,s),ot(e.data[0],r,o,s),it(e,r,s)}getPaintedCanvas(e,t,r){return t?(this.imprintVectorAnimationLinesStep(e,r),e.ctxStreamLines.canvas):e.ctxFill.canvas}imprintVectorAnimationLinesStep({data:e,ctxFill:t,ctxStreamLines:r},n){let{layer:s}=this;r.clearRect(0,0,256,256),r.drawImage(t.canvas,0,0),!(e.slines.length===0||s.style.streamLineStatic||s.style.streamLineColor==="none")&&lt(e,r,s,n)}};function rt(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let o=0,i=0,c=259;o<256;++o,c+=2)for(let l=0;l<256;++l,++i,++c)e[i]=s[n[c]];else e.fill(0)}function at(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:o}=t,i=[];if(r.isolineColor!=="none"){let c=r.isolineColor[0]==="#"?C(r.isolineColor):0;for(let l=0,u=0;l<256;l+=1)for(let f=0;f<256;f+=1){let d=(l+1)*258+(f+1),g=n[d],x=n[d+1],m=n[d+258];if(!g||!x||!m)continue;let p=s[g],b=s[x],W=s[m];if(p!==b||p!==W){let w=Math.max(p,b,W),T=Math.max(g,x,m),S=l*256+f;switch(r.isolineColor){case"inverted":a[S]=~o[T]|4278190080;break;case"fill":a[S]=o[T]|4278190080;break;default:a[S]=c;break}r.isolineText&&!(++u%255)&&f>20&&f<235&&l>20&&l<235&&i.push({x:f,y:l,d:g,dr:x,db:m,mli:w})}}}return i}function nt(a,e,{CLUT:t}){if(a.length){e.font="1.1em Sans-serif",e.lineWidth=2,e.strokeStyle="white",e.fillStyle="black",e.textAlign="center",e.textBaseline="middle";for(let{x:r,y:n,d:s,dr:o,db:i,mli:c}of a){let l=t.ticks[c].dataString,u=Math.atan2(s-o,i-s);e.save(),e.translate(r,n),e.rotate(u<-1.57||u>1.57?u+3.14:u),e.strokeText(l,0,0),e.fillText(l,0,0),e.restore()}}}function st(a,e,{CLUT:t,style:r}){if(!t.DataToKnots||r.vectorColor==="none"||r.vectorType==="none")return;if(a.length!==3)throw new Error("data.length !== 3");let[n,s,o]=a;switch(r.vectorType){case"barbs":e.font="40px barbs";break;case"arrows":e.font="50px arrows";break;default:e.font=r.vectorType}e.textAlign="center",e.textBaseline="middle",e.fillStyle=r.vectorColor;let i=r.addDegrees?.017453292519943*r.addDegrees:0,c=32;for(let l=c/2;l<256;l+=c)for(let u=c/2;u<256;u+=c){let f=u+1+(l+1)*258;if(!n.raw[f])continue;let d=Math.atan2(s.dmin+s.raw[f]*s.dmul,o.dmin+o.raw[f]*o.dmul),g=n.dmin+n.raw[f]*n.dmul,x=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,m=Math.min(t.DataToKnots(g)*x,25)+65,p=String.fromCharCode(m);switch(r.vectorColor){case"inverted":e.fillStyle=M(~t.colorsI[n.raw[f]]);break;case"fill":e.fillStyle=M(t.colorsI[n.raw[f]]);break}e.save(),e.translate(u,l),e.rotate(d+i),e.fillText(p,0,0),e.restore()}}function ot(a,e,t,{CLUT:r,style:n}){if(t!=="degree")return;let s=.017453292519943*n.addDegrees;e.font="50px arrows",e.textAlign="center",e.textBaseline="middle",e.fillStyle=n.vectorColor;let o="L",i=32;for(let c=i/2;c<256;c+=i)for(let l=i/2;l<256;l+=i){let u=l+1+(c+1)*258;if(!a.raw[u])continue;let d=(a.dmin+a.raw[u]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=M(~r.colorsI[a.raw[u]]);break;case"fill":e.fillStyle=M(r.colorsI[a.raw[u]]);break}e.save(),e.translate(l,c),e.rotate(d+s),e.fillText(o,0,0),e.restore()}}function it(a,e,{CLUT:t,style:r}){let{data:n,slines:s}=a;if(!s.length||!r.streamLineStatic||r.streamLineColor==="none")return;let o=n[0];e.lineWidth=1,e.strokeStyle=r.streamLineColor;for(let i=s.length;i--;){let c=s[i];for(let l=0;l<c.length-1;++l){let u=c[l],f=c[l+1],d=u.x+1+(u.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=M(~t.colorsI[o.raw[d]]);break;case"fill":e.strokeStyle=M(t.colorsI[o.raw[d]]);break}e.beginPath(),e.moveTo(u.x,u.y),e.lineTo(f.x,f.y),e.stroke()}}}function lt(a,e,{CLUT:t,style:r},n){let{data:s,slines:o}=a,i=s[0],c=r.streamLineColor.substring(0,7);n=n>>5;for(let l=0;l<o.length;++l){let u=o[l],f=u.length-1,d=(n+(1+u[0].x)*(1+u[0].y))%30;for(let g=0;g<f;++g){let x=u[g],m=u[g+1],p=1-(d-g)/f;(p<0||p>1)&&(p=0);let b=(~~(p*255)).toString(16).padStart(2,"0"),W=1+~~((1.2-p)*5);e.lineWidth=W;let w=x.x+1+(x.y+1)*258;switch(r.streamLineColor){case"inverted":c=M(~t.colorsI[i.raw[w]]);break;case"fill":c=M(t.colorsI[i.raw[w]]);break}e.strokeStyle=c+b,e.beginPath(),e.moveTo(x.x,x.y),e.lineTo(m.x,m.y),e.stroke()}}}var V=class{constructor({time:e,variables:t,wxdatasetManager:r,ext:n="png",wxstyleName:s="base"}){this.tilesCache=new Map;this.painter=new F(this);this.loader=new Z(this);if(!(t!=null&&t.length)||t.length>2)throw new Error(`WxTileSource ${r.datasetName}: only 1 or 2 variables are supported but ${t.length} were given`);t.forEach(o=>{if(!r.checkVariableValid(o))throw new Error(`WxTileSource ${r.datasetName}: variable ${o} is not valid`)}),this.variables=t,this.wxdatasetManager=r,this.ext=n,this.currentMeta=this._getCurrentMeta(),[this.tilesURIs,this.time]=this._createURLsAndTime(e),[this.style,this.CLUT]=this._createCurrentStyleObject(A()[s]),h(`WxTileSource created ${r.datasetName}, ${t.join(", ")}, ${s}`)}get nonanimatable(){return this.variables.length<2||this.style.streamLineStatic||this.style.streamLineColor==="none"}getTime(){return this.time}clearCache(){this.tilesCache.clear(),this.loader.clearCache()}getCurrentStyleObjectCopy(){return Object.assign({},this.style)}updateCurrentStyleObject(e){[this.style,this.CLUT]=this._createCurrentStyleObject(e)}getTileData(e,t){let r=this.tilesCache.get(Y(e));if(!r)return;let n=this._getPixelInfo(t,r.data.data);if(!n)return;let{raw:s,data:o}=n,i=s.map(u=>this.CLUT.colorsI[u]),c=i.map(M),l=o.map(u=>this.CLUT.DataToStyle(u));return{data:o,raw:s,rgba:i,hexColor:c,inStyleUnits:l,tilePoint:t,styleUnits:this.style.units,dataUnits:this.currentMeta.units}}setURLsAndTime(e){[this.tilesURIs,this.time]=this._createURLsAndTime(e)}loadTile(e,t){return y(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t)})}preloadTime(e,t,r){return y(this,null,function*(){let[n]=this._createURLsAndTime(e);yield Promise.allSettled(t.map(s=>this.loader.cacheLoad(s,n,r)))})}reloadTiles(e,t){return y(this,null,function*(){var n;let r=new Map;yield Promise.allSettled(e.map(s=>this._loadCacheDrawTile(s,r,t))),(n=t==null?void 0:t.signal)!=null&&n.aborted||(this.tilesCache=r)})}_loadCacheDrawTile(e,t,r){return y(this,null,function*(){let n=t.get(Y(e));if(n)return n;let s=yield this.loader.load(e,r);if(!s)return null;let o=I(256,256),i=o,c=this.variables.length===2?I(256,256):o,l={ctxFill:o,ctxText:i,ctxStreamLines:c,data:s};return this.painter.paint(l),t.set(Y(e),l),l})}_createCurrentStyleObject(e){let t=Object.assign(this.getCurrentStyleObjectCopy(),e);t.streamLineColor=ye(t.streamLineColor);let r=this._prepareCLUT(t);return[t,r]}_getCurrentMeta(){let e=this.variables.map(o=>{let i=this.wxdatasetManager.getVariableMeta(o);if(!i)throw new Error(`WxTileSource ${this.wxdatasetManager.datasetName}: variable ${o} is not valid`);return i}),{min:t,max:r,units:n,vector:s}=e[0];return this.variables.length>1&&(t=0,r=1.42*Math.max(-e[0].min,e[0].max,-e[1].min,e[1].max)),{min:t,max:r,units:n,vector:s}}_getPixelInfo({x:e,y:t},r){var s,o;let n=(t+1)*258+(e+1);if(!!((o=(s=r==null?void 0:r[0])==null?void 0:s.raw)!=null&&o[n]))return{raw:r.map(i=>i.raw[n]),data:r.map(i=>i.raw[n]*i.dmul+i.dmin)}}_prepareCLUT(e){let{min:t,max:r,units:n}=this.currentMeta;return new N(e,n,[t,r],this.variables.length===2)}_createURLsAndTime(e){let t=this.wxdatasetManager.getValidTime(e);return[this.variables.map(n=>this.wxdatasetManager.createURI(n,t,this.ext)),t]}};var Ae=Be(Re()),B=class extends Ae.default.GridLayer{};var G=class extends B{constructor(t,r){super(r);this.animation=!1;this.animationSeed=0;this.layer=new V(t)}get wxdatasetManager(){return this.layer.wxdatasetManager}getMetadata(){return h(`WxTileSource getMetadata (${this.layer.wxdatasetManager.datasetName})`),X({},this.layer.currentMeta)}getVariables(){return h(`WxTileSource getVariables (${this.layer.wxdatasetManager.datasetName})`),[...this.layer.variables]}clearCache(){h(`WxTileSource clearCache (${this.layer.wxdatasetManager.datasetName})`),this.layer.clearCache()}getCurrentStyleObjectCopy(){return h(`WxTileSource getCurrentStyleObjectCopy (${this.layer.wxdatasetManager.datasetName})`),this.layer.getCurrentStyleObjectCopy()}getTime(){return h(`WxTileSource getTime (${this.layer.wxdatasetManager.datasetName})`),this.layer.getTime()}setTime(t,r){return y(this,null,function*(){var s;h(`WxTileSource setTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t});let n=this.getTime();return this.layer.setURLsAndTime(t),yield this._reloadVisible(r),(s=r==null?void 0:r.signal)!=null&&s.aborted&&this.layer.setURLsAndTime(n),this.getTime()})}preloadTime(t,r){return y(this,null,function*(){return h(`WxTileSource preloadTime (${this.layer.wxdatasetManager.datasetName}) `,{time:t}),this.layer.preloadTime(t,this.coveringTiles(),r)})}startAnimation(){if(this.animation){h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) already started`);return}if(this.layer.nonanimatable){h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName}) nonanimatable`);return}h(`WxTileSource startAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!0;let t=r=>y(this,null,function*(){if(h(`WxTileSource animationStep (${this.layer.wxdatasetManager.datasetName})`),!this.animation||this.layer.nonanimatable){this.animation=!1;return}this.animationSeed=r,yield this._redrawTiles(),requestAnimationFrame(t)});requestAnimationFrame(t)}stopAnimation(){return y(this,null,function*(){return h(`WxTileSource stopAnimation (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return y(this,null,function*(){return h(`WxTileSource setCoarseLevel (${this.layer.wxdatasetManager.datasetName})`,{level:t}),this.oldMaxZoom=this.layer.wxdatasetManager.getMaxZoom(),this.layer.wxdatasetManager.meta.maxZoom=Math.max(this.oldMaxZoom-t,1),this._reloadVisible()})}unsetCoarseLevel(){return y(this,null,function*(){if(h(`WxTileSource unsetCoarseLevel (${this.layer.wxdatasetManager.datasetName})`),this.oldMaxZoom)return this.layer.wxdatasetManager.meta.maxZoom=this.oldMaxZoom,this._reloadVisible()})}setStyleByName(t,r=!0){return y(this,null,function*(){return h(`WxTileSource setStyleByName (${this.layer.wxdatasetManager.datasetName})`),this.updateCurrentStyleObject(A()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return y(this,null,function*(){if(h(`WxTileSource updateCurrentStyleObject (${this.layer.wxdatasetManager.datasetName})`,{style:t}),this.layer.updateCurrentStyleObject(t),this.startAnimation(),r)return this._reloadVisible(n)})}_redrawTiles(){return this.redrawRequested?this.redrawRequested:(this.redrawRequested=new Promise(t=>{requestAnimationFrame(()=>{h(`WxTileSource _redrawTiles (${this.layer.wxdatasetManager.datasetName})`),this.update(),t(),this.redrawRequested=void 0})}),this.redrawRequested)}_reloadVisible(t){return y(this,null,function*(){})}coveringTiles(){return[]}update(){}};var z=class{constructor(e,t,r){this.coords=e;this.ctx=t;this.raster_data=r;this.draw(r==null?void 0:r.ctxFill.canvas)}draw(e){this.ctx.clearRect(0,0,256,256),e&&this.ctx.drawImage(e,0,0)}},se=class extends G{constructor(e,t){super(e,t),h("WxTileSource constructor: ",e)}getLayerInfoAtLatLon(e,t){if(h(`WxTileSource getLayerInfoAtLatLon (${this.layer.wxdatasetManager.datasetName})`,e),!this._map)return;let r=this._map.getZoom(),n=this._map.project(e,r),s=n.divideBy(256).floor(),o=n.subtract(s.multiplyBy(256)).floor();return this.layer.getTileData({x:s.x,y:s.y,z:r},o)}_reloadVisible(e){return y(this,null,function*(){var t;if(h(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName})`),yield this.layer.reloadTiles(this.coveringTiles(),e),(t=e==null?void 0:e.signal)!=null&&t.aborted){h(`WxTileSource _reloadVisible (${this.layer.wxdatasetManager.datasetName}) aborted`);return}return yield Promise.allSettled(this._ForEachWxTile(r=>y(this,null,function*(){r.raster_data=yield this.layer.loadTile(r.coords)}),"_reloadVisible")),this._redrawTiles()})}coveringTiles(){var t;h(`WxTileSource coveringTiles (${this.layer.wxdatasetManager.datasetName})`);let e=[];for(let r in this._tiles){let n=(t=this._tiles[r].el)==null?void 0:t.wxtile;n&&e.push(n.coords)}return e}update(){this._ForEachWxTile(e=>{e.draw(e.raster_data&&this.layer.painter.getPaintedCanvas(e.raster_data,this.animation,this.animationSeed))},"_redrawTiles")}_ForEachWxTile(e,t){var n;h(`WxTileSource _ForEachWxTile (${this.layer.wxdatasetManager.datasetName}) func=${t}`);let r=[];for(let s in this._tiles){let o=(n=this._tiles[s].el)==null?void 0:n.wxtile;o&&r.push(e(o))}return r}createTile(e,t){let r=I(256,256),n=r.canvas;return this.layer.loadTile(e).then(s=>{n.wxtile=new z(e,r,s)}).catch(()=>{n.wxtile=new z(e,r,null)}).finally(t),n}onRemove(){return h(`WxTileSource onRemove (${this.layer.wxdatasetManager.datasetName})`),this.animation=!1,this.clearCache(),this}};export{B as FrameworkParentClass,Z as Loader,F as Painter,U as QTree,N as RawCLUT,h as WXLOG,te as WxAPI,De as WxCreateLegend,O as WxDataSetManager,H as WxGetColorSchemes,A as WxGetColorStyles,V as WxLayer,se as WxTileSource,je as WxTilesLogging};
1
+ var Ue=Object.create;var H=Object.defineProperty,$e=Object.defineProperties,Be=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertyNames,le=Object.getOwnPropertySymbols,Oe=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable;var ce=(a,e,t)=>e in a?H(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,L=(a,e)=>{for(var t in e||(e={}))me.call(e,t)&&ce(a,t,e[t]);if(le)for(var t of le(e))Fe.call(e,t)&&ce(a,t,e[t]);return a},ue=(a,e)=>$e(a,Ve(e));var Ne=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports);var Ze=(a,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xe(e))!me.call(a,n)&&n!==t&&H(a,n,{get:()=>e[n],enumerable:!(r=Be(e,n))||r.enumerable});return a};var Ee=(a,e,t)=>(t=a!=null?Ue(Oe(a)):{},Ze(e||!a||!a.__esModule?H(t,"default",{value:a,enumerable:!0}):t,a));var b=(a,e,t)=>new Promise((r,n)=>{var s=m=>{try{i(t.next(m))}catch(l){n(l)}},o=m=>{try{i(t.throw(m))}catch(l){n(l)}},i=m=>m.done?r(m.value):Promise.resolve(m.value).then(s,o);i((t=t.apply(a,e)).next())});var Re=Ne((jt,Ae)=>{Ae.exports=window.L});var fe={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 de={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 xe,pe,ge;function he({colorStyles:a={},units:e={},colorSchemes:t={}}={}){u("WxTile lib setup: start"),xe=Object.assign({},fe,e),pe=Object.assign({},t,de);let r=Object.assign({},a,E);ge=Ye(r),u("WxTile lib setup: styles unrolled");try{b(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 ge}function Q(){return pe}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({},xe,t),s=n[a],o=n[e];if(!s||!o)return u("Inconvertible units. Trivial converter"),r;let[i,m,l]=s,[c,d,p]=o;if(i!==c||!m||!d)return u("Inconvertible units. Trivial converter"),r;let h=m/d,x=((l||0)-(p||0))/d;return x?f=>h*f+x:f=>h*f}function Ye(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 m=r(s,i.parent);return Object.assign(i,Object.assign({},m,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 qe(a,e){return b(this,null,function*(){return createImageBitmap(yield(yield fetch(a,e)).blob())})}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 je(a){let{width:e,height:t}=a,r=R(e,t);return r.drawImage(a,0,0),r.getImageData(0,0,e,t)}function ee(a,e){return b(this,null,function*(){return je(yield qe(a,e))})}function Ge(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,m=ze(t);return{raw:t,dmin:s,dmax:o,dmul:i,integral:m,radius:0}}function te(a,e){return b(this,null,function*(){return Ge(yield ee(a,e))})}function ze(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 be(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),m=Math.min(e,s-1,t-1-s),l=t*(s-m-1)+o,c=t*(s+m)+o,d;if(n){let W=n[l-i-1],S=n[l+i],y=n[c-i-1],D=n[c+i];d=W+D-S-y}else d=(2*i+1)*(2*m+1);let p=r[l-i-1],h=r[l+i],x=r[c-i-1],f=r[c+i],g=p+f-h-x;a.raw[s*t+o]=g/d}return a}function M(a){let e=a>>0&255,t=a>>8&255,r=a>>16&255,n=e.toString(16),s=t.toString(16),o=r.toString(16);return n=n.length===2?n:"0"+n,s=s.length===2?s:"0"+s,o=o.length===2?o:"0"+o,"#"+n+s+o}function I(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 b(this,null,function*(){let t=yield fetch(a,e);if(!t.ok)throw new Error("error:"+a+" - "+t.statusText);return t.json()})}function re(a,e,t){let r=a>>0&255,n=a>>8&255,s=a>>16&255,o=a>>>24,i=e>>0&255,m=e>>8&255,l=e>>16&255,c=e>>>24,d=r+t*(i-r),p=n+t*(m-n),h=s+t*(l-s),x=o+t*(c-o);return d|p<<8|h<<16|x<<24}function ye(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 Ke(a){J=!!a,console.log("WXLOGing",J),u=typeof a=="function"?a:J?console.log:()=>{}}function ae(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 He="A".charCodeAt(0);var $=class{constructor(){this.qtree={nodes:null};this.qtreedepth=0;u("QTree.constructor")}load(e,t){return b(this,null,function*(){try{let r=yield A(e,t);this.qtree=We(r,{pos:0})}catch(r){throw new Error(`Failed to load QTree: ${r.message}`)}this.qtreedepth=Se(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}:L({},e);return we(this.qtree,n,r)}};function We(a,e){let t=a.charCodeAt(e.pos)-He;e.pos++;let r=[1,2,4,8].map(n=>t&n?We(a,e):null);return{nodes:r.some(n=>n)?r:null}}function Se(a){return a!=null&&a.nodes?1+Math.max(...a.nodes.map(Se)):0}function we(a,e,t){return a===null?"land":t&&!e.z?"mixed":a.nodes===null?"sea":e.z?(e.z--,we(a.nodes[(e.y>>e.z&1)<<1|e.x>>e.z&1],e,t)):"mixed"}function Je(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 m=Y(e.units,t,e.extraUnits),l=f=>~~(65535*Je((m(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(l(f))}else{if(e.levels||(e.levels=ye(this.DataToStyle(r),this.DataToStyle(n),10)),e.levels.sort((f,g)=>f<g?-1:f>g?1:0),!e.colors){let f=Q();e.colorScheme&&e.colorScheme in f?e.colors=f[e.colorScheme]:e.colors=f.wb}for(let f of e.levels)i.push(l(f))}let c=65536,d=Te(c,e);this.ticks=d.ticks;let p=d.ticks[0].data,x=d.ticks[d.ticks.length-1].data-p;for(let f=0;f<65536;++f){let g=o*f/65535+r,W=this.DataToStyle(g),S=Math.round((c-1)*(W-p)/x);S<=0?this.colorsI[f]=e.showBelowMin?d.colors[0]:0:S>=c?this.colorsI[f]=e.showAboveMax?d.colors[c-1]:0:this.colorsI[f]=d.colors[S]}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 De(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 p=r[0][0],h=r[r.length-1][0]-p;for(let[x,f]of r){let g=~~((x-p)/h*(a-1)),W={data:x,dataString:De(x),color:f,pos:g};t.ticks.push(W)}for(let x=0;x<r.length-1;x++){let f=t.ticks[x].pos,g=t.ticks[x+1].pos,W=I(r[x][1]),S=o?I(r[x+1][1]):0;for(let y=f;y<g;++y)t.colors[y]=o?re(W,S,(y-f)/(g-f)):W}return t.colors[a-1]=I(r[r.length-1][1]),t}if(!s||!n)return t;let i=0,m=0,l=-1;for(let p=0;p<a;++p){let h=p*(s.length-1)/a;l!==~~h&&(l=~~h,i=I(s[l]),m=s.length>l+1?I(s[l+1]):i),t.colors[p]=o?re(i,m,h-l):i}t.colors[a-1]=I(s[s.length-1]);let c=n[0],d=(a-1)/(n[n.length-1]-c);for(let p of n){let h=~~((p-c)*d),x={data:p,dataString:De(p),color:M(t.colors[h]),pos:h};t.ticks.push(x)}return t}var Qe=2*Math.PI*6378137/256,G=2*Math.PI*6378137/2;function et(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 tt(a,e,t){let r=rt(t),n=a*r-G,s=e*r-G;return[n,s]}function rt(a){return Qe/Math.pow(2,a)}function ne(a,e,t){let[r,n]=et(...tt(a,e,t));return[n,-r]}function Me(a,e){return[a*256,e*256]}function se(a,e,t){let r=((e-a)%360+540)%360-180;return(a+r*t+360)%360}function at(a,e,t,r,n,s,o,i){switch((a?1:0)|(e?2:0)|(t?4:0)|(r?8:0)){case 0:return 0;case 1:return a;case 2:return e;case 3:t=a,r=e;break;case 4:return t;case 5:e=a,r=t;break;case 6:r=e+t>>1,a=r;break;case 7:r=e+t>>1;break;case 8:return r;case 9:e=a+r>>1,t=e;break;case 10:a=e,t=r;break;case 11:t=a+r>>1;break;case 12:a=t,e=r;break;case 13:e=a+r>>1;break;case 14:a=e+t>>1;break}a=o+i*a,e=o+i*e,t=o+i*t,r=o+i*r;let l=se(a,e,n),c=se(t,r,n);return(se(l,c,s)-o)/i||1}function nt(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 Ce(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:m,dmul:l}=e,c={raw:new Uint16Array(258*258),dmin:i,dmax:m,dmul:l},{raw:d}=c;for(let p=-1,h=0,x=s-r+1;p<=256;p++,x+=r){let f=Math.floor(x),g=x-f,W=f*258;for(let S=-1,y=n-r+1;S<=256;S++,h++,y+=r){let D=Math.floor(y),T=y-D,w=D+W,C=o[w],v=o[w+1],P=o[w+258],k=o[w+258+1];d[h]=a(C,v,P,k,T,g,i,l)}}return c}function Le(a,e,t){if(!e)return a;let r=c=>c<0?0:c>254?254:c,n=1/Math.pow(2,e.z),s=e.x*256*n-.5,o=e.y*256*n-.5,{data:i}=a,m=new ImageData(256,256),{data:l}=m;for(let c=0,d=t,p=o;c<256;c++,p+=n){let h=~~r(p),x=p-h,f=h*256;for(let g=0,W=s;g<256;g++,d+=4,W+=n){let S=~~r(W),y=W-S,D=(S+f)*4+t,T=i[D],w=i[D+4],C=i[D+4*256],v=i[D+4*256+4],P=y+x<1?y*(w-T)+x*(C-T)+T:y*(v-C)+x*(v-w)+w+C-v;l[d]=P>127?255:0}}return m}function ve(a,e){return e?Ce(nt,a,e):a}function Ie(a,e){return e?Ce(at,a,e):a}function Pe(a,{data:e},t,r){let n=r==="sea",{raw:s}=a;for(let o=t,i=259,m=0;m<256;i+=2,m++)for(let l=0;l<256;l++,i++,o+=4)n===!e[o]&&(s[i]=0);return a}function ke(a){let[e,t]=Me(a.x,a.y),[r,n]=ne(e,t,a.z),[s,o]=ne(e+256,t+256,a.z);return{west:r,north:n,east:s,south:o}}function oe(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(te);this.layer=e}load(e,t){return b(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,m=i==="degree"?Ie:ve,l=d=>m(be(d,this.layer.style.blurRadius),s),c=n.map(l);return this._vectorMagnitudesPrepare(c),yield this._applyMask(c,e,o,!s&&n.length===1),{data:c,slines:this._createStreamLines(c)}})}cacheLoad(e,t,r){return b(this,null,function*(){if(!this._checkInsideBoundaries(e))return null;let n=this._checkTypeAndMask(e);if(!n)return null;let{upCoords:s,subCoords:o}=oe(e,this.layer.wxdatasetManager.getMaxZoom()),i=t.map(c=>q(c,s)),m=Object.assign({},this.layer.wxdatasetManager.wxapi.requestInit,{signal:r==null?void 0:r.signal});return{rawdata:yield Promise.all(i.map(c=>this.loadDataFunc(c,m))),subCoords:o,tileType:n}})}clearCache(){this.loadDataFunc=U(te)}_applyMask(e,t,r,n){return b(this,null,function*(){let{style:s}=this.layer;if((s.mask==="land"||s.mask==="sea")&&r==="mixed"){if(n){let{raw:i,dmin:m,dmax:l,dmul:c}=e[0];e[0]={raw:new Uint16Array(i),dmin:m,dmax:l,dmul:c}}let o;try{let{upCoords:i,subCoords:m}=oe(t,this.layer.wxdatasetManager.wxapi.maskDepth);o=yield this.layer.wxdatasetManager.wxapi.loadMaskFunc(i),o=Le(o,m,this.layer.wxdatasetManager.wxapi.maskChannel)}catch(i){s.mask=void 0,u("Can't load Mask. Masking is disabled");return}Pe(e[0],o,this.layer.wxdatasetManager.wxapi.maskChannel,s.mask)}})}_vectorMagnitudesPrepare(e){if(e.length===1)return;e.unshift({raw:new Uint16Array(258*258),dmin:0,dmax:0,dmul:0});let[t,r,n]=e;t.dmax=1.42*Math.max(-r.dmin,r.dmax,-n.dmin,n.dmax),t.dmul=(t.dmax-t.dmin)/65535;for(let s=0;s<258*258;++s){if(!r.raw[s]||!n.raw[s])continue;let o=r.dmin+r.dmul*r.raw[s],i=n.dmin+n.dmul*n.raw[s];t.raw[s]=Math.sqrt(i*i+o*o)/t.dmul}}_checkTypeAndMask(e){let{mask:t}=this.layer.style;var r="mixed";if(!((t==="land"||t==="sea")&&(r=this.layer.wxdatasetManager.wxapi.qtree.check(e),t===r)))return r}_checkInsideBoundaries(e){let t=this.layer.wxdatasetManager.getBoundaries();if(t!=null&&t.boundaries180){let r=ke(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,m=t.addDegrees?.017453292519943*t.addDegrees:0,l=t.streamLineGridStep||64,c=t.streamLineSteps||300;for(let d=0;d<=256;d+=l)for(let p=0;p<=256;p+=l){if(!n.raw[1+p+(1+d)*258])continue;let h=[],x=p,f=d,g=-1,W=0,S=0;for(let T=0;T<=c&&x>=0&&x<=256&&f>=0&&f<=256;T++){T%(c/10)||h.push({x:~~x,y:~~f});let w=~~x+1+(~~f+1)*258;if(w!==g){if(!n.raw[w])break;g=w;let C=n.dmin+n.raw[w]*n.dmul,v=s.dmin+s.raw[w]*s.dmul,P=o.dmin+o.raw[w]*o.dmul,k=Math.atan2(v,P)+m;W=i*C*Math.sin(k),S=i*C*Math.cos(k)}x+=W,f-=S}let y=p,D=d;g=-1;for(let T=1;T<=c&&y>=0&&y<=256&&D>=0&&D<=256;T++){T%(c/10)||h.unshift({x:~~y,y:~~D});let w=~~y+1+(~~D+1)*258;if(w!==g){if(!n.raw[w])break;g=w;let C=n.dmin+n.raw[w]*n.dmul,v=s.dmin+s.raw[w]*s.dmul,P=o.dmin+o.raw[w]*o.dmul,k=Math.atan2(v,P)+m;W=i*C*Math.sin(k),S=i*C*Math.cos(k)}y-=W,D+=S}h.length>2&&r.push(h)}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),m=new Uint32Array(i.data.buffer);t.clearRect(0,0,256,256),r.clearRect(0,0,256,256),n.clearRect(0,0,256,256),st(e.data[0],m,s);let l=ot(m,e.data[0],s);t.putImageData(i,0,0),it(l,r,s),lt(e.data,r,s),ct(e.data[0],r,o,s),mt(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")&&ut(e,r,s,n)}};function st(a,e,{CLUT:t,style:r}){let{raw:n}=a,{colorsI:s}=t;if(r.fill!=="none")for(let o=0,i=0,m=259;o<256;++o,m+=2)for(let l=0;l<256;++l,++i,++m)e[i]=s[n[m]];else e.fill(0)}function ot(a,e,{CLUT:t,style:r}){let{raw:n}=e,{levelIndex:s,colorsI:o}=t,i=[];if(r.isolineColor!=="none"){let m=r.isolineColor[0]==="#"?I(r.isolineColor):0;for(let l=0,c=0;l<256;l+=1)for(let d=0;d<256;d+=1){let p=(l+1)*258+(d+1),h=n[p],x=n[p+1],f=n[p+258];if(!h||!x||!f)continue;let g=s[h],W=s[x],S=s[f];if(g!==W||g!==S){let y=Math.max(g,W,S),D=Math.max(h,x,f),T=l*256+d;switch(r.isolineColor){case"inverted":a[T]=~o[D]|4278190080;break;case"fill":a[T]=o[D]|4278190080;break;default:a[T]=m;break}r.isolineText&&!(++c%255)&&d>20&&d<235&&l>20&&l<235&&i.push({x:d,y:l,d:h,dr:x,db:f,mli:y})}}}return i}function it(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:m}of a){let l=t.ticks[m].dataString,c=Math.atan2(s-o,i-s);e.save(),e.translate(r,n),e.rotate(c<-1.57||c>1.57?c+3.14:c),e.strokeText(l,0,0),e.fillText(l,0,0),e.restore()}}}function lt(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,m=32;for(let l=m/2;l<256;l+=m)for(let c=m/2;c<256;c+=m){let d=c+1+(l+1)*258;if(!n.raw[d])continue;let p=Math.atan2(s.dmin+s.raw[d]*s.dmul,o.dmin+o.raw[d]*o.dmul),h=n.dmin+n.raw[d]*n.dmul,x=r.vectorType!=="barbs"?r.vectorFactor*.2:.2,f=Math.min(t.DataToKnots(h)*x,25)+65,g=String.fromCharCode(f);switch(r.vectorColor){case"inverted":e.fillStyle=M(~t.colorsI[n.raw[d]]);break;case"fill":e.fillStyle=M(t.colorsI[n.raw[d]]);break}e.save(),e.translate(c,l),e.rotate(p+i),e.fillText(g,0,0),e.restore()}}function ct(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 m=i/2;m<256;m+=i)for(let l=i/2;l<256;l+=i){let c=l+1+(m+1)*258;if(!a.raw[c])continue;let p=(a.dmin+a.raw[c]*a.dmul+180)*.01745329251;switch(n.vectorColor){case"inverted":e.fillStyle=M(~r.colorsI[a.raw[c]]);break;case"fill":e.fillStyle=M(r.colorsI[a.raw[c]]);break}e.save(),e.translate(l,m),e.rotate(p+s),e.fillText(o,0,0),e.restore()}}function mt(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=ae(r.streamLineColor));for(let i=s.length;i--;){let m=s[i];for(let l=0;l<m.length-1;++l){let c=m[l],d=m[l+1],p=c.x+1+(c.y+1)*258;switch(r.streamLineColor){case"inverted":e.strokeStyle=M(~t.colorsI[o.raw[p]]);break;case"fill":e.strokeStyle=M(t.colorsI[o.raw[p]]);break}e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(d.x,d.y),e.stroke()}}}function ut(a,e,{CLUT:t,style:r},n){let{data:s,slines:o}=a,i=s[0],m=r.streamLineColor[0]==="#"?ae(r.streamLineColor).substring(0,7):"#000000";n=n>>5;for(let l=0;l<o.length;++l){let c=o[l],d=c.length-1,p=(n+(1+c[0].x)*(1+c[0].y))%30;for(let h=0;h<d;++h){let x=c[h],f=c[h+1],g=1-(p-h)/d;(g<0||g>1)&&(g=0);let W=(~~(g*255)).toString(16).padStart(2,"0"),S=1+~~((1.2-g)*5);e.lineWidth=S;let y=x.x+1+(x.y+1)*258;switch(r.streamLineColor){case"inverted":m=M(~t.colorsI[i.raw[y]]);break;case"fill":m=M(t.colorsI[i.raw[y]]);break}e.strokeStyle=m+W,e.beginPath(),e.moveTo(x.x,x.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:
2
+ datasetName: ${e.wxdatasetManager.datasetName},
3
+ variables: ${e.variables.join(", ")},
4
+ wxstyleName: ${e.wxstyleName},
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(L(L(L({},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(c=>this.CLUT.colorsI[c]),m=i.map(M),l=o.map(c=>this.CLUT.DataToStyle(c));return{data:o,raw:s,rgba:i,hexColor:m,inStyleUnits:l,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 b(this,null,function*(){return this._loadCacheDrawTile(e,this.tilesCache,t)})}preloadTime(e,t,r){return b(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 b(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 b(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,m=this.variables.length===2?R(256,256):o,l={ctxFill:o,ctxText:i,ctxStreamLines:m,data:s};return this.painter.paint(l),t.set(j(e),l),l})}_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=Ee(Re()),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})`),L({},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 b(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 b(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=>b(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 b(this,null,function*(){return u(`WxLayerBaseImplementation.stopAnimation (${this.id})`),this.animation=!1,this._redrawTiles()})}setCoarseLevel(t=2){return b(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 b(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 b(this,null,function*(){return u(`WxLayerBaseImplementation.setStyleByName (${this.id}) wxstyleName=${t} reload=${r}`),this.updateCurrentStyleObject(_()[t],r)})}updateCurrentStyleObject(t,r=!0,n){return b(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 b(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 b(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=>b(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,wxapi:s}){if(!s.datasetsMetas.allDatasetsList.includes(e))throw new Error(`Dataset ${e} not found`);this.datasetName=e,this.instanced=r,this.instance=t,this.meta=n,this.wxapi=s,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"){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.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=ue(L({},e),{variables:this.checkCombineVariableIfVector(e.variable),wxdatasetManager:this});return new N(r,t)}checkDatasetOutdated(){return b(this,null,function*(){return u(`WxDataSetManager.checkDatasetOutdated: ${this.datasetName}`),yield this.wxapi.initDone,(yield this.getDatasetInstance())===this.instance})}getDatasetInstance(){return b(this,null,function*(){u(`WxDataSetManager.getDatasetInstance: ${this.datasetName}`);let e=yield this.getDatasetInstances();return e[e.length-1]})}getDatasetInstances(){return b(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 ie=class{constructor({dataServerURL:e,maskURL:t="auto",maskChannel:r="R",maskDepth:n=9,qtreeURL:s="auto",requestInit:o,colorStyles:i,units:m,colorSchemes:l}){this.maskURL="auto";this.datasetsMetas={allDatasetsList:[]};this.qtree=new $;this.loadMaskFunc=()=>Promise.reject(new Error("maskURL not defined"));if(u("WxAPI.constructor",e),he({colorStyles:i,units:m,colorSchemes:l}),this.dataServerURL=e,this.requestInit=o,s=s==="auto"?e+"masks/9+1.seamask.qtree":s,t!=="none"){let c=U(ee);this.maskURL=t=t==="auto"?e+"masks/{z}/{x}/{y}.png":t,this.loadMaskFunc=d=>c(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(([c,d])=>{c.allDatasetsList||(c.allDatasetsList=Object.keys(c)),this.datasetsMetas=c,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 b(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 b(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=yield A(this.dataServerURL+e+"/"+r+"/meta.json",this.requestInit);return new Z({datasetName:e,instanced:n,instance:r,meta:s,wxapi:this})})}createAllDatasetsManagers(){return b(this,null,function*(){return yield this.initDone,u("WxAPI.createAllDatasetsManagers"),Promise.allSettled(this.datasetsMetas.allDatasetsList.map(t=>this.createDatasetManager(t)))})}filterDatasetsByVariableName(e){return b(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 b(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,ie as WxAPI,Te as WxCreateLegend,Z as WxDataSetManager,Q as WxGetColorSchemes,_ as WxGetColorStyles,O as WxLayer,N as WxTileSource,Ke as WxTilesLogging};
@@ -31,79 +31,97 @@ export interface ColorStylesIncomplete {
31
31
  }
32
32
  /** Strict style interface */
33
33
  export interface WxColorStyleStrict {
34
- /** name of the style */
34
+ /** Name of the style */
35
35
  name: string;
36
- /** name of a parent style to inherit from */
36
+ /** Name of a parent style to inherit from */
37
37
  parent?: string;
38
- /** fill schema. 'none' means no fill. 'solid' means solid fill. 'gradient' means gradient fill. */
38
+ /** Tile filling schema.
39
+ * - **'none'** means no fill, leave the tile transparent
40
+ * - **'solid'** means solid fill, no gradient between levels.
41
+ * - **'gradient'** means gradient fill.
42
+ * */
39
43
  fill: 'none' | 'gradient' | 'solid';
40
44
  /**
41
- * color of isolines.
42
- * 'none' means no isolines.
43
- * 'inverted' use inverted value of {@link fill} in each pixel.
44
- * 'fill' means use value of {@link fill} in each pixel. */
45
+ * Color of isolines.
46
+ * - **'none'** do not render.
47
+ * - **'fill'** using value of {@link fill} in each pixel.
48
+ * - **'inverted'** using *inverted* value of {@link fill} in each pixel.
49
+ * - **'#RGB'** or '**#RRGGBB**' or '**#RRGGBBAA**' - using this WEB-color.
50
+ * */
45
51
  isolineColor: 'none' | 'inverted' | 'fill' | `#${string}`;
46
52
  /** if true then render isoline text values */
47
53
  isolineText: boolean;
48
54
  /**
49
- * 'none' means no vectors.
50
- * 'arrows' means render vectors as arrows.
51
- * 'barbs' means render vectors as barbs.*/
55
+ * Representation of the wind/current field.
56
+ * - **'none'** do not render vectors.
57
+ * - **'arrows'** use arrows to represent winds/currents.
58
+ * - **'barbs'** use barbs.
59
+ * */
52
60
  vectorType: 'none' | 'arrows' | 'barbs';
53
61
  /**
54
- * color of vectors
55
- * 'none' means no vectors.
56
- * 'inverted' use inverted value of {@link fill} in each pixel.
57
- * 'fill' means use value of {@link fill} in each pixel.
58
- * '#RRGGBB' means use this color for vectors. */
62
+ * Color of vectors.
63
+ * - **'none'** do not render vectors.
64
+ * - **'fill'** using value of {@link fill} in each pixel.
65
+ * - **'inverted'** using *inverted* value of {@link fill} in each pixel.
66
+ * - **'#RGB'** or '**#RRGGBB**' or '**#RRGGBBAA**' - using this WEB-color.
67
+ * */
59
68
  vectorColor: 'none' | 'inverted' | 'fill' | `#${string}`;
60
- /** factor to scale vector length */
69
+ /** Factor for vectors length */
61
70
  vectorFactor: number;
62
71
  /**
63
- * Draw streamlines.
64
- * 'none' means no streamlines.
65
- * 'inverted' use inverted value of {@link fill} in each pixel.
66
- * 'fill' means use value of {@link fill} in each pixel.
67
- * '#RRGGBB' means use this color for streamlines. */
72
+ * Draw streamlines:
73
+ * - **'none'** means no streamlines.
74
+ * - **'fill'** using value of {@link fill} in each pixel.
75
+ * - **'inverted'** using *inverted* value of {@link fill} in each pixel.
76
+ * - **'#RGB'** or '**#RRGGBB**' or '**#RRGGBBAA**' - using this WEB-color.
77
+ * */
68
78
  streamLineColor: 'none' | 'inverted' | 'fill' | `#${string}`;
69
79
  /** factor to scale streamlines length */
70
80
  streamLineSpeedFactor: number;
71
81
  /**
72
82
  * Step to seed streamlines. Streamlines spread both ways from seed point.
73
- * less value means more streamlines. */
83
+ * less value means more streamlines.
84
+ * */
74
85
  streamLineGridStep?: number;
75
86
  /** steps in each streamline */
76
87
  streamLineSteps?: number;
77
- /** if true then render streamlines as static lines.
78
- * if false then render streamlines as animated lines. */
88
+ /**
89
+ * - if true then render streamlines as static lines.
90
+ * - if false then render streamlines as animated lines.
91
+ * */
79
92
  streamLineStatic: boolean;
80
- /** if true then fill values below style's minimum. */
93
+ /** If true then fill values below style's minimum. */
81
94
  showBelowMin: boolean;
82
- /** if true then fill values above style's maximum. */
95
+ /** If true then fill values above style's maximum. */
83
96
  showAboveMax: boolean;
84
- /** color scheme name from the default set. May be extended in {@link WxAPI}*/
97
+ /** Color scheme name from the default set. May be extended in {@link WxAPI}*/
85
98
  colorScheme: string;
86
- /** colors. Used if presented instead of colorScheme */
99
+ /** Used if presented instead of colorScheme */
87
100
  colors?: string[];
88
- /** color map. Used if presented instead of levels, colors, colorScheme*/
101
+ /**
102
+ * Used if presented instead of levels, colors, colorScheme.
103
+ * Array of [level,color] tuples. Colors are WEB-colors.
104
+ */
89
105
  colorMap?: [number, string][];
90
- /** levels. Used if presented, otherwise 10 levels are evenly calculated from given data */
106
+ /** Levels to build legend. Used if presented, otherwise 10 levels are calculated evenly on given data */
91
107
  levels?: number[];
92
108
  /** radius for the BOX filter */
93
109
  blurRadius: number;
94
- /** rotate vectors by this angle */
110
+ /** Additional rotation of all wind or current's vectors or directions by angle in degrees.*/
95
111
  addDegrees: number;
96
112
  /** Units of the style (from the default set)*/
97
113
  units: string;
98
114
  /**
99
- * Additional units for the style to be used within {@link units}.
100
- * @see {@link WxUnits} */
115
+ * Additional extend of default {@link units}.
116
+ * @see {@link WxUnits}
117
+ * */
101
118
  extraUnits?: WxUnits;
102
119
  /**
103
- * masking
104
- * 'none' means no masking.
105
- * 'sea' means mask sea.
106
- * 'land' means mask land. */
120
+ * masking:
121
+ * - **'none'** - no masking.
122
+ * - **'sea'** - make sea transparent.
123
+ * - **'land'** - make land transparent.
124
+ * */
107
125
  mask?: 'land' | 'sea' | 'none';
108
126
  }
109
127
  /**
@@ -150,8 +168,10 @@ export interface Converter {
150
168
  * @param customUnits - custom units to use if needed
151
169
  * @returns a function that converts a value from one unit to another
152
170
  * @example
171
+ * ```ts
153
172
  * const convert = makeConverter('m/s', 'km/h');
154
173
  * const speed = convert(10); // speed is now 36
174
+ * ```
155
175
  * */
156
176
  export declare function makeConverter(from: string, to: string, customUnits?: WxUnits): Converter;
157
177
  /** Function type to load image from URL, with additional properties */
@@ -182,7 +202,8 @@ export interface DataPicture {
182
202
  export type DataPictures = [DataPicture] | [DataPicture, DataPicture, DataPicture];
183
203
  /**
184
204
  * interface extends {@link DataPictures} with {@link IntegralPare} and current
185
- * calculated radius of the box-filter */
205
+ * calculated radius of the box-filter
206
+ * */
186
207
  export interface DataIntegral extends DataPicture {
187
208
  integral: IntegralPare;
188
209
  radius: number;
@@ -275,15 +296,14 @@ export declare function createLevels(min: number, max: number, n: number): numbe
275
296
  * */
276
297
  export declare function getClosestTimeString(times: string[], time: Date | string | number): string;
277
298
  /**
278
- * Set logging on/off
279
- * @param logging - true to turn on logging
299
+ * Logging helper
280
300
  * */
281
- export declare function WxTilesLogging(on: boolean): void;
301
+ export declare let WXLOG: (...args: any[]) => void;
282
302
  /**
283
- * Logging helper
284
- * @param args - arguments to log
303
+ * Set logging on/off
304
+ * @param logging - true to turn on logging
285
305
  * */
286
- export declare function WXLOG(...str: any): void;
306
+ export declare function WxTilesLogging(on?: boolean | ((...args: any[]) => void)): void;
287
307
  /**
288
308
  * Helper to convert short form of web color from '#RGB' to '#RRGGBB'
289
309
  * @param color - web color in format '#RGB' or '#RRGGBB' or '#RRGGBBAA'
@@ -1,5 +1,10 @@
1
- import type { WxDate, WxVars } from '../wxlayer/wxlayer';
1
+ import type { WxDate, WxLayerOptions, WxVars } from '../wxlayer/wxlayer';
2
+ import { WxTileSource } from '../wxsource/wxsource';
3
+ import { FrameworkOptions } from '../wxsource/wxsourcetypes';
2
4
  import type { WxDatasetMeta, WxAPI, WxVariableMeta, WxAllBoundariesMeta } from './wxAPI';
5
+ export interface WxSourceLayerOptions extends Omit<WxLayerOptions, 'variables' | 'wxdatasetManager'> {
6
+ variable: string;
7
+ }
3
8
  /**
4
9
  * Options to pass to the constructor of {@link WxDataSetManager}
5
10
  */
@@ -108,6 +113,7 @@ export declare class WxDataSetManager {
108
113
  * @returns {WxVars} - [variable] or [variable.eastward, variable.northward]
109
114
  * */
110
115
  checkCombineVariableIfVector(variable: string): WxVars;
116
+ createSourceLayer(options: WxSourceLayerOptions, frwOptions: FrameworkOptions): WxTileSource;
111
117
  /**
112
118
  * Check if dataset's instance updated (fresh data is arrived) since datasset object was created
113
119
  * @returns {boolean} - true if dataset's instance updated since datasset object was created
@@ -52,7 +52,7 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
52
52
  * @ignore
53
53
  * Used to make coarse level requests for time animation
54
54
  * */
55
- protected oldMaxZoom?: number;
55
+ protected readonly oldMaxZoom: number;
56
56
  /**
57
57
  * @ignore
58
58
  * An instance of the layer
@@ -65,9 +65,9 @@ export declare class WxLayerBaseImplementation extends FrameworkParentClass impl
65
65
  protected redrawRequested?: Promise<void>;
66
66
  /**
67
67
  * @internal
68
- * Do not use this constructo directly
68
+ * Do not use this constructor directly
69
69
  * */
70
- constructor(wxlayeroptions: WxLayerOptions, options?: FrameworkOptions);
70
+ constructor(wxLayerOptions: WxLayerOptions, frwOptions: FrameworkOptions);
71
71
  /**
72
72
  * returns the dataset manager of the source
73
73
  * @returns {WxDataSetManager} the dataset manager of the source
@@ -6,7 +6,7 @@ import { WxBoundaryMeta } from '../wxAPI/wxAPI';
6
6
  * @param {XYZ | undefined} subCoords - subtile coordinates
7
7
  * @returns {ImageData} subtile data
8
8
  * */
9
- export declare function subMask(inputData: ImageData, subCoords?: XYZ): ImageData;
9
+ export declare function subMask(inputData: ImageData, subCoords: XYZ | undefined, channel: number): ImageData;
10
10
  /**
11
11
  * Get sub-tile of a regular data via baricemrtric interpolation
12
12
  * @param {DataPicture} inputData - input data
@@ -45,11 +45,7 @@ export interface WxLngLat {
45
45
  }
46
46
  /**
47
47
  * Options to construct {@link WxTileSource} object
48
- * @example
49
- * ```ts
50
- * const variables = wxdatasetManager.checkCombineVariableIfVector('air.temperature.at-2m');
51
- * const options: WxLayerOptions = { variables, wxdatasetManager, time: Date.now() };
52
- * ```
48
+ * Do not use this type directly, use {@link WxLayerOptions} instead
53
49
  * */
54
50
  export interface WxLayerOptions {
55
51
  /** Variables of the layer */
@@ -62,6 +58,8 @@ export interface WxLayerOptions {
62
58
  ext?: 'png';
63
59
  /** initial style name */
64
60
  wxstyleName?: string;
61
+ /** initial style, applyed on top of style passed by name {@link wxstyleName} */
62
+ wxstyle?: WxColorStyleWeak;
65
63
  }
66
64
  /**
67
65
  * @internal
@@ -90,7 +88,7 @@ export declare class WxLayer {
90
88
  readonly painter: Painter;
91
89
  /** @internal Loader object to load and preprocess tiles */
92
90
  protected readonly loader: Loader;
93
- constructor({ time, variables, wxdatasetManager, ext, wxstyleName }: WxLayerOptions);
91
+ constructor(wxLayerOptions: WxLayerOptions);
94
92
  /** Check if the layer is vector and may be animated according to style */
95
93
  get nonanimatable(): boolean;
96
94
  /**
@@ -130,7 +128,7 @@ export declare class WxLayer {
130
128
  /** @ignore */
131
129
  protected _loadCacheDrawTile(tile: XYZ, tilesCache: Map<string, WxRasterData>, requestInit?: WxRequestInit): Promise<WxRasterData | null>;
132
130
  /** @ignore */
133
- protected _createCurrentStyleObject(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
131
+ protected _createStyleAndCLUT(style_?: WxColorStyleWeak): [WxColorStyleStrict, RawCLUT];
134
132
  /** @ignore creates/calculates meta data for vector layers */
135
133
  protected _getCurrentMeta(): WxVariableMeta;
136
134
  /** @ignore x, y - pixel on tile, data - data tile */
@@ -37,7 +37,7 @@ export declare class WxTileSource extends WxLayerBaseImplementation implements W
37
37
  * @param {WxLayerOptions} wxlayeroptions - The options for the {@link WxLayerBaseImplementation}.
38
38
  * @param {FrameworkOptions} frameworkOptions - The options for the framework.
39
39
  */
40
- constructor(wxlayeroptions: WxLayerOptions, frameworkOptions?: FrameworkOptions);
40
+ constructor(wxlayeroptions: WxLayerOptions, frameworkOptions: FrameworkOptions);
41
41
  /**
42
42
  * Get comprehensive information about the current point on map.
43
43
  * @param {WxLngLat} lnglat - Coordinates of the point.
@@ -76,6 +76,6 @@ export declare class WxTileSource extends WxLayerBaseImplementation implements W
76
76
  * @internal
77
77
  * @description Used by framework. Cleans up resources used by the source.
78
78
  */
79
- onRemove(): this;
79
+ onRemove(map: L.Map): this;
80
80
  }
81
81
  export {};
@@ -6,6 +6,8 @@ import L from 'leaflet';
6
6
  * Used as universal type for the custom source parent class. see {@link WxTileSource}
7
7
  */
8
8
  export declare class FrameworkParentClass extends L.GridLayer {
9
+ id: string;
10
+ constructor(options: FrameworkOptions);
9
11
  }
10
12
  /**
11
13
  * Framework's basic options to construct the layer.
@@ -15,4 +17,5 @@ export declare class FrameworkParentClass extends L.GridLayer {
15
17
  * ```
16
18
  */
17
19
  export interface FrameworkOptions extends L.GridLayerOptions {
20
+ id: string;
18
21
  }