-
Notifications
You must be signed in to change notification settings - Fork 7
/
interpolateHeatmapLayer.js
executable file
·1 lines (1 loc) · 24.3 KB
/
interpolateHeatmapLayer.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.interpolateHeatmapLayer=e():t.interpolateHeatmapLayer=e()}(this,(()=>(()=>{var t={570:t=>{"use strict";function e(t,e,r){r=r||2;var n,a,o,h,u,g,m,x=e&&e.length,p=x?e[0]*r:t.length,d=i(t,0,p,r,!0),v=[];if(!d||d.next===d.prev)return v;if(x&&(d=function(t,e,r,s){var n,a,o,h=[];for(n=0,a=e.length;n<a;n++)(o=i(t,e[n]*s,n<a-1?e[n+1]*s:t.length,s,!1))===o.next&&(o.steiner=!0),h.push(c(o));for(h.sort(l),n=0;n<h.length;n++)r=f(h[n],r);return r}(t,e,d,r)),t.length>80*r){n=o=t[0],a=h=t[1];for(var T=r;T<p;T+=r)(u=t[T])<n&&(n=u),(g=t[T+1])<a&&(a=g),u>o&&(o=u),g>h&&(h=g);m=0!==(m=Math.max(o-n,h-a))?32767/m:0}return s(d,v,r,n,a,m,0),v}function i(t,e,i,r,s){var n,a;if(s===y(t,e,i,r)>0)for(n=e;n<i;n+=r)a=_(n,t[n],t[n+1],a);else for(n=i-r;n>=e;n-=r)a=_(n,t[n],t[n+1],a);return a&&d(a,a.next)&&(A(a),a=a.next),a}function r(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!d(r,r.next)&&0!==p(r.prev,r,r.next))r=r.next;else{if(A(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function s(t,e,i,l,f,u,c){if(t){!c&&u&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=g(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,a,o,h,l=1;do{for(i=t,t=null,n=null,a=0;i;){for(a++,r=i,o=0,e=0;e<l&&(o++,r=r.nextZ);e++);for(h=l;o>0||h>0&&r;)0!==o&&(0===h||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,h--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,l*=2}while(a>1)}(s)}(t,l,f,u);for(var m,x,p=t;t.prev!==t.next;)if(m=t.prev,x=t.next,u?a(t,l,f,u):n(t))e.push(m.i/i|0),e.push(t.i/i|0),e.push(x.i/i|0),A(t),t=x.next,p=x.next;else if((t=x)===p){c?1===c?s(t=o(r(t),e,i),e,i,l,f,u,2):2===c&&h(t,e,i,l,f,u):s(r(t),e,i,l,f,u,1);break}}}function n(t){var e=t.prev,i=t,r=t.next;if(p(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,a=r.x,o=e.y,h=i.y,l=r.y,f=s<n?s<a?s:a:n<a?n:a,u=o<h?o<l?o:l:h<l?h:l,g=s>n?s>a?s:a:n>a?n:a,c=o>h?o>l?o:l:h>l?h:l,x=r.next;x!==e;){if(x.x>=f&&x.x<=g&&x.y>=u&&x.y<=c&&m(s,o,n,h,a,l,x.x,x.y)&&p(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function a(t,e,i,r){var s=t.prev,n=t,a=t.next;if(p(s,n,a)>=0)return!1;for(var o=s.x,h=n.x,l=a.x,f=s.y,u=n.y,c=a.y,x=o<h?o<l?o:l:h<l?h:l,d=f<u?f<c?f:c:u<c?u:c,v=o>h?o>l?o:l:h>l?h:l,T=f>u?f>c?f:c:u>c?u:c,E=g(x,d,e,i,r),R=g(v,T,e,i,r),b=t.prevZ,_=t.nextZ;b&&b.z>=E&&_&&_.z<=R;){if(b.x>=x&&b.x<=v&&b.y>=d&&b.y<=T&&b!==s&&b!==a&&m(o,f,h,u,l,c,b.x,b.y)&&p(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,_.x>=x&&_.x<=v&&_.y>=d&&_.y<=T&&_!==s&&_!==a&&m(o,f,h,u,l,c,_.x,_.y)&&p(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;b&&b.z>=E;){if(b.x>=x&&b.x<=v&&b.y>=d&&b.y<=T&&b!==s&&b!==a&&m(o,f,h,u,l,c,b.x,b.y)&&p(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;_&&_.z<=R;){if(_.x>=x&&_.x<=v&&_.y>=d&&_.y<=T&&_!==s&&_!==a&&m(o,f,h,u,l,c,_.x,_.y)&&p(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function o(t,e,i){var s=t;do{var n=s.prev,a=s.next.next;!d(n,a)&&v(n,s,s.next,a)&&R(n,a)&&R(a,n)&&(e.push(n.i/i|0),e.push(s.i/i|0),e.push(a.i/i|0),A(s),A(s.next),s=t=a),s=s.next}while(s!==t);return r(s)}function h(t,e,i,n,a,o){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&x(h,l)){var f=b(h,l);return h=r(h,h.next),f=r(f,f.next),s(h,e,i,n,a,o,0),void s(f,e,i,n,a,o,0)}l=l.next}h=h.next}while(h!==t)}function l(t,e){return t.x-e.x}function f(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,a=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var o=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=s&&o>a&&(a=o,i=r.x<r.next.x?r:r.next,o===s))return i}r=r.next}while(r!==e);if(!i)return null;var h,l=i,f=i.x,g=i.y,c=1/0;r=i;do{s>=r.x&&r.x>=f&&s!==r.x&&m(n<g?s:a,n,f,g,n<g?a:s,n,r.x,r.y)&&(h=Math.abs(n-r.y)/(s-r.x),R(r,t)&&(h<c||h===c&&(r.x>i.x||r.x===i.x&&u(i,r)))&&(i=r,c=h)),r=r.next}while(r!==l);return i}(t,e);if(!i)return e;var s=b(i,t);return r(s,s.next),r(i,i.next)}function u(t,e){return p(t.prev,t,e.prev)<0&&p(e.next,t,t.next)<0}function g(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function c(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function m(t,e,i,r,s,n,a,o){return(s-a)*(e-o)>=(t-a)*(n-o)&&(t-a)*(r-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function x(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&v(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(R(t,e)&&R(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(p(t.prev,t,e.prev)||p(t,e.prev,e))||d(t,e)&&p(t.prev,t,t.next)>0&&p(e.prev,e,e.next)>0)}function p(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function d(t,e){return t.x===e.x&&t.y===e.y}function v(t,e,i,r){var s=E(p(t,e,i)),n=E(p(t,e,r)),a=E(p(i,r,t)),o=E(p(i,r,e));return s!==n&&a!==o||!(0!==s||!T(t,i,e))||!(0!==n||!T(t,r,e))||!(0!==a||!T(i,t,r))||!(0!==o||!T(i,e,r))}function T(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function E(t){return t>0?1:t<0?-1:0}function R(t,e){return p(t.prev,t,t.next)<0?p(t,e,t.next)>=0&&p(t,t.prev,e)>=0:p(t,e,t.prev)<0||p(t,t.next,e)<0}function b(t,e){var i=new F(t.i,t.x,t.y),r=new F(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function _(t,e,i,r){var s=new F(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function F(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function y(t,e,i,r){for(var s=0,n=e,a=i-r;n<i;n+=r)s+=(t[a]-t[n])*(t[n+1]+t[a+1]),a=n;return s}t.exports=e,t.exports.default=e,e.deviation=function(t,e,i,r){var s=e&&e.length,n=s?e[0]*i:t.length,a=Math.abs(y(t,0,n,i));if(s)for(var o=0,h=e.length;o<h;o++){var l=e[o]*i,f=o<h-1?e[o+1]*i:t.length;a-=Math.abs(y(t,l,f,i))}var u=0;for(o=0;o<r.length;o+=3){var g=r[o]*i,c=r[o+1]*i,m=r[o+2]*i;u+=Math.abs((t[g]-t[m])*(t[c+1]-t[g+1])-(t[g]-t[c])*(t[m+1]-t[g+1]))}return 0===a&&0===u?0:Math.abs((u-a)/a)},e.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},r=0,s=0;s<t.length;s++){for(var n=0;n<t[s].length;n++)for(var a=0;a<e;a++)i.vertices.push(t[s][n][a]);s>0&&(r+=t[s-1].length,i.holes.push(r))}return i}},788:t=>{t.exports="precision mediump float;\n\nVALUE_TO_COLOR\nVALUE_TO_COLOR_4\n\nuniform sampler2D maskTexture;\nuniform sampler2D idwTexture;\nuniform vec2 screenSize;\nuniform bool circlesDrawn;\nuniform float opacity;\nuniform float averageThreshold;\nuniform float average;\n\nvoid main(void) {\n vec4 mask = texture2D(maskTexture, vec2(gl_FragCoord.x/screenSize.x, gl_FragCoord.y/screenSize.y));\n vec4 idw = texture2D(idwTexture, vec2(gl_FragCoord.x/screenSize.x, gl_FragCoord.y/screenSize.y));\n\n if (mask.x > 0. && (!circlesDrawn || mask.y > 0.) && idw.z > 0.) {\n float u = idw.x/idw.y;\n if (abs(u - average) >= averageThreshold) {\n gl_FragColor = valueToColor4(u, opacity);\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n } else {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n}"},638:t=>{t.exports="attribute vec4 position;\nuniform mat4 mvpMatrix;\n\nvoid main() {\n gl_Position = mvpMatrix * position;\n}"},236:t=>{t.exports="precision highp float;\n\nuniform float ui;\nuniform vec2 xi;\nuniform float p;\nuniform vec2 framebufferSize;\nuniform mat4 mvpMatrixInverse;\nuniform float pointRadius;\nuniform vec2 xiImageSpace;\nuniform bool fasterPointRadius;\n\nvoid main() {\n vec2 x = vec2(2. * gl_FragCoord.x/framebufferSize.x - 1., 2. * gl_FragCoord.y/framebufferSize.y - 1.);\n float wi = 1.0/pow(distance(x, xiImageSpace), p);\n\n float outsideRange = 1.;\n if (fasterPointRadius) {\n vec4 xWorldSpace = mvpMatrixInverse * vec4(x, 1, 1);\n xWorldSpace /= xWorldSpace.w;\n \n if (distance(vec2(xWorldSpace), xi) > pointRadius) {\n outsideRange = 0.;\n }\n }\n\n gl_FragColor = vec4(ui*wi, wi, outsideRange, 0.0);\n}"},630:t=>{t.exports="attribute vec2 position;\nuniform mat4 mvpMatrix;\n\nvoid main() {\n gl_Position = mvpMatrix * vec4(position, 0.0, 1.0);\n}"},688:t=>{t.exports="precision mediump float;\n\nuniform bool drawingCircles;\n\nvoid main() {\n if (drawingCircles) {\n gl_FragColor = vec4(0., 1., 0., 0.);\n } else {\n gl_FragColor = vec4(1., 0., 0., 0.);\n }\n}"},498:t=>{t.exports="attribute vec2 position;\nuniform mat4 mvpMatrix;\nuniform mat4 modelMatrix;\n\nvoid main() {\n gl_Position = mvpMatrix * modelMatrix * vec4(position, 0.0, 1.0);\n}"}},e={};function i(r){var s=e[r];if(void 0!==s)return s.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,i),n.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";i.r(r),i.d(r,{create:()=>p});class t{#t;constructor(){this.#t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}getElements(){return this.#t}translate(t,e,i){return this.#t[12]+=this.#t[0]*t+this.#t[4]*e+this.#t[8]*i,this.#t[13]+=this.#t[1]*t+this.#t[5]*e+this.#t[9]*i,this.#t[14]+=this.#t[2]*t+this.#t[6]*e+this.#t[10]*i,this.#t[15]+=this.#t[3]*t+this.#t[7]*e+this.#t[11]*i,this}scale(t,e,i){return this.#t[0]*=t,this.#t[4]*=e,this.#t[8]*=i,this.#t[1]*=t,this.#t[5]*=e,this.#t[9]*=i,this.#t[2]*=t,this.#t[6]*=e,this.#t[10]*=i,this.#t[3]*=t,this.#t[7]*=e,this.#t[11]*=i,this}static dot(t,e){const i=new Float32Array(4);for(let r=0;r<4;r++)i[r]=t[r+0]*e[0]+t[r+4]*e[1]+t[r+8]*e[2]+t[r+12]*e[3];return i}static inverse(t){const e=new Float32Array(16);e[0]=t[5]*t[10]*t[15]-t[5]*t[11]*t[14]-t[9]*t[6]*t[15]+t[9]*t[7]*t[14]+t[13]*t[6]*t[11]-t[13]*t[7]*t[10],e[4]=-t[4]*t[10]*t[15]+t[4]*t[11]*t[14]+t[8]*t[6]*t[15]-t[8]*t[7]*t[14]-t[12]*t[6]*t[11]+t[12]*t[7]*t[10],e[8]=t[4]*t[9]*t[15]-t[4]*t[11]*t[13]-t[8]*t[5]*t[15]+t[8]*t[7]*t[13]+t[12]*t[5]*t[11]-t[12]*t[7]*t[9],e[12]=-t[4]*t[9]*t[14]+t[4]*t[10]*t[13]+t[8]*t[5]*t[14]-t[8]*t[6]*t[13]-t[12]*t[5]*t[10]+t[12]*t[6]*t[9],e[1]=-t[1]*t[10]*t[15]+t[1]*t[11]*t[14]+t[9]*t[2]*t[15]-t[9]*t[3]*t[14]-t[13]*t[2]*t[11]+t[13]*t[3]*t[10],e[5]=t[0]*t[10]*t[15]-t[0]*t[11]*t[14]-t[8]*t[2]*t[15]+t[8]*t[3]*t[14]+t[12]*t[2]*t[11]-t[12]*t[3]*t[10],e[9]=-t[0]*t[9]*t[15]+t[0]*t[11]*t[13]+t[8]*t[1]*t[15]-t[8]*t[3]*t[13]-t[12]*t[1]*t[11]+t[12]*t[3]*t[9],e[13]=t[0]*t[9]*t[14]-t[0]*t[10]*t[13]-t[8]*t[1]*t[14]+t[8]*t[2]*t[13]+t[12]*t[1]*t[10]-t[12]*t[2]*t[9],e[2]=t[1]*t[6]*t[15]-t[1]*t[7]*t[14]-t[5]*t[2]*t[15]+t[5]*t[3]*t[14]+t[13]*t[2]*t[7]-t[13]*t[3]*t[6],e[6]=-t[0]*t[6]*t[15]+t[0]*t[7]*t[14]+t[4]*t[2]*t[15]-t[4]*t[3]*t[14]-t[12]*t[2]*t[7]+t[12]*t[3]*t[6],e[10]=t[0]*t[5]*t[15]-t[0]*t[7]*t[13]-t[4]*t[1]*t[15]+t[4]*t[3]*t[13]+t[12]*t[1]*t[7]-t[12]*t[3]*t[5],e[14]=-t[0]*t[5]*t[14]+t[0]*t[6]*t[13]+t[4]*t[1]*t[14]-t[4]*t[2]*t[13]-t[12]*t[1]*t[6]+t[12]*t[2]*t[5],e[3]=-t[1]*t[6]*t[11]+t[1]*t[7]*t[10]+t[5]*t[2]*t[11]-t[5]*t[3]*t[10]-t[9]*t[2]*t[7]+t[9]*t[3]*t[6],e[7]=t[0]*t[6]*t[11]-t[0]*t[7]*t[10]-t[4]*t[2]*t[11]+t[4]*t[3]*t[10]+t[8]*t[2]*t[7]-t[8]*t[3]*t[6],e[11]=-t[0]*t[5]*t[11]+t[0]*t[7]*t[9]+t[4]*t[1]*t[11]-t[4]*t[3]*t[9]-t[8]*t[1]*t[7]+t[8]*t[3]*t[5],e[15]=t[0]*t[5]*t[10]-t[0]*t[6]*t[9]-t[4]*t[1]*t[10]+t[4]*t[2]*t[9]+t[8]*t[1]*t[6]-t[8]*t[2]*t[5];let i=t[0]*e[0]+t[1]*e[4]+t[2]*e[8]+t[3]*e[12];if(0!=i){i=1/i;for(let t=0;t<16;t++)e[t]=e[t]*i;return e}}}function e(t){return t.getParameter(t.VERSION).includes("2.0")}function s(t,e){return h(t,t.createShader(t.VERTEX_SHADER),e)}function n(t,e){return h(t,t.createShader(t.FRAGMENT_SHADER),e)}function a(t,e,i){const r=t.createProgram();if(t.attachShader(r,e),t.attachShader(r,i),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS))throw t.getProgramInfoLog(r);return r}function o(t,e,i){if(e!=t.ARRAY_BUFFER&&e!=t.ELEMENT_ARRAY_BUFFER)throw new Error(`The provided buffer type ${e} has an invalid value.`);const r=t.createBuffer();return t.bindBuffer(e,r),t.bufferData(e,i,t.STATIC_DRAW),r}function h(t,e,i){if(t.shaderSource(e,i),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))throw t.getShaderInfoLog(e);return e}var l=i(570),f=i.n(l);class u{static#e=50;#i;#r;#s;#n;#a;#o;#h;#l;#f;#u;#g;#c;#m;#x;constructor(t,e,i,r,s,n){this.#i=t,this.#r=e,this.#s=i,this.#a=n,this.#p(r,s),this.#d(),this.#v(),this.#T(),this.#E(),this.#R(),this.#b()}delete(){this.#i.deleteTexture(this.#m),this.#g&&(this.#i.deleteBuffer(this.#g.vertexBuffer),this.#i.deleteBuffer(this.#g.indexBuffer)),this.#i.deleteBuffer(this.#c.vertexBuffer),this.#i.deleteBuffer(this.#c.indexBuffer),this.#i.deleteFramebuffer(this.#x)}draw(t){this.#i.disable(this.#i.DEPTH_TEST),this.#i.enable(this.#i.BLEND),this.#i.blendFunc(this.#i.ONE,this.#i.ONE),this.#i.useProgram(this.#o),this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,this.#x),this.#i.viewport(0,0,this.#r,this.#s),this.#i.clear(this.#i.COLOR_BUFFER_BIT),this.#i.uniformMatrix4fv(this.#l,!1,t),this.#g&&this.#_(),this.#A()}getTexture(){return this.#m}updatePointsAndDistances(t,e){this.#p(t,e),this.#E()}#p(e,i){if(this.#n=[],e.length==i.length)for(let r=0;r<e.length;r++){const s=e[r],n=i[r],a=new t;a.translate(s[0],s[1],0),a.scale(n,n,0),this.#n.push(a)}}#d(){this.#o=a(this.#i,s(this.#i,i(498)),n(this.#i,i(688)))}#v(){this.#h=this.#i.getAttribLocation(this.#o,"position"),this.#l=this.#i.getUniformLocation(this.#o,"mvpMatrix"),this.#f=this.#i.getUniformLocation(this.#o,"modelMatrix"),this.#u=this.#i.getUniformLocation(this.#o,"drawingCircles")}#E(){if(this.#g&&(this.#i.deleteBuffer(this.#g.vertexBuffer),this.#i.deleteBuffer(this.#g.indexBuffer)),this.#g=void 0,this.#n.length>0){const t=[],e=[],i=u.#e,r=2*Math.PI/i;t.push(0,0);for(let s=0;s<i+1;s++){const n=s*r,a=Math.cos(n),o=Math.sin(n);t.push(a,o),s<i&&e.push(0,s+1,s+2)}this.#g={vertexBuffer:o(this.#i,this.#i.ARRAY_BUFFER,new Float32Array(t)),indexBuffer:o(this.#i,this.#i.ELEMENT_ARRAY_BUFFER,new Uint8Array(e)),numberOfIndices:e.length}}}#T(){const t=[];if(0==this.#a.length)t.push(1,1,-1,1,-1,-1,1,-1);else for(let e of this.#a)t.push(e[0],e[1]);const e=f()(t);this.#c={vertexBuffer:o(this.#i,this.#i.ARRAY_BUFFER,new Float32Array(t)),indexBuffer:o(this.#i,this.#i.ELEMENT_ARRAY_BUFFER,new Uint8Array(e)),numberOfIndices:e.length}}#R(){this.#m=this.#i.createTexture(),this.#i.bindTexture(this.#i.TEXTURE_2D,this.#m),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_WRAP_S,this.#i.CLAMP_TO_EDGE),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_WRAP_T,this.#i.CLAMP_TO_EDGE),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_MAG_FILTER,this.#i.NEAREST),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_MIN_FILTER,this.#i.NEAREST),this.#i.texImage2D(this.#i.TEXTURE_2D,0,this.#i.RGB,this.#r,this.#s,0,this.#i.RGB,this.#i.UNSIGNED_SHORT_5_6_5,null),this.#i.bindTexture(this.#i.TEXTURE_2D,null)}#b(){this.#x=this.#i.createFramebuffer(),this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,this.#x),this.#i.framebufferTexture2D(this.#i.FRAMEBUFFER,this.#i.COLOR_ATTACHMENT0,this.#i.TEXTURE_2D,this.#m,0),this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,null)}#_(){this.#i.uniform1i(this.#u,1),this.#i.bindBuffer(this.#i.ARRAY_BUFFER,this.#g.vertexBuffer),this.#i.enableVertexAttribArray(this.#h),this.#i.vertexAttribPointer(this.#h,2,this.#i.FLOAT,!1,0,0),this.#i.bindBuffer(this.#i.ELEMENT_ARRAY_BUFFER,this.#g.indexBuffer);for(let t=0;t<this.#n.length;t++)this.#i.uniformMatrix4fv(this.#f,!1,this.#n[t].getElements()),this.#i.drawElements(this.#i.TRIANGLES,this.#g.numberOfIndices,this.#i.UNSIGNED_BYTE,0)}#A(){this.#i.uniform1i(this.#u,0),this.#i.bindBuffer(this.#i.ARRAY_BUFFER,this.#c.vertexBuffer),this.#i.enableVertexAttribArray(this.#h),this.#i.vertexAttribPointer(this.#h,2,this.#i.FLOAT,!1,0,0),this.#i.bindBuffer(this.#i.ELEMENT_ARRAY_BUFFER,this.#c.indexBuffer),this.#i.uniformMatrix4fv(this.#f,!1,(new t).getElements()),this.#i.drawElements(this.#i.TRIANGLES,this.#c.numberOfIndices,this.#i.UNSIGNED_BYTE,0)}}class g{#i;#F;#y;#B;#M;#w;#P;#U;#C;#o;#h;#l;#L;#S;#D;#I;#O;#N;#z;#X;#Z;constructor(t,e,i,r,s,n,a,o,h){this.#i=t,this.#F=e,this.#y=i,this.#B=r,this.#M=s,this.#w=n,this.#P=a,this.#U=o,this.#C=h,this.#d(),this.#v(),this.#G()}delete(){this.#i.deleteBuffer(this.#X)}draw(t,e,i,r,s){this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,null),this.#i.viewport(0,0,r,s),this.#i.enable(this.#i.DEPTH_TEST),this.#i.enable(this.#i.BLEND),this.#i.blendFunc(this.#U,this.#C),this.#i.useProgram(this.#o),this.#i.bindBuffer(this.#i.ARRAY_BUFFER,this.#X),this.#i.enableVertexAttribArray(this.#h),this.#i.vertexAttribPointer(this.#h,2,this.#i.FLOAT,!1,0,0),this.#i.uniformMatrix4fv(this.#l,!1,t),this.#i.activeTexture(this.#i.TEXTURE0),this.#i.bindTexture(this.#i.TEXTURE_2D,e),this.#i.uniform1i(this.#L,0),this.#i.activeTexture(this.#i.TEXTURE1),this.#i.bindTexture(this.#i.TEXTURE_2D,i),this.#i.uniform1i(this.#S,1),this.#i.uniform2f(this.#D,r,s),this.#i.uniform1i(this.#I,this.#F),this.#i.uniform1f(this.#O,this.#y),this.#i.uniform1f(this.#z,this.#P),this.#i.uniform1f(this.#N,this.#w),this.#i.drawArrays(this.#i.TRIANGLE_STRIP,0,this.#Z)}#d(){this.#o=a(this.#i,s(this.#i,i(638)),n(this.#i,i(788).replace("VALUE_TO_COLOR",this.#B).replace("VALUE_TO_COLOR_4",this.#M)))}#v(){this.#h=this.#i.getAttribLocation(this.#o,"position"),this.#l=this.#i.getUniformLocation(this.#o,"mvpMatrix"),this.#L=this.#i.getUniformLocation(this.#o,"maskTexture"),this.#S=this.#i.getUniformLocation(this.#o,"idwTexture"),this.#D=this.#i.getUniformLocation(this.#o,"screenSize"),this.#I=this.#i.getUniformLocation(this.#o,"circlesDrawn"),this.#O=this.#i.getUniformLocation(this.#o,"opacity"),this.#N=this.#i.getUniformLocation(this.#o,"average"),this.#z=this.#i.getUniformLocation(this.#o,"averageThreshold")}#G(){this.#X=o(this.#i,this.#i.ARRAY_BUFFER,new Float32Array([1,1,-1,1,1,-1,-1,-1])),this.#Z=4}}class c{static#H=2*Math.PI*6371008.8;#W;#V;#Y;constructor(t,e){this.#W=t,this.#V=(180+e)/360,this.#Y=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}getX(){return this.#V}getY(){return this.#Y}meterInMercatorCoordinateUnits(){return 1/c.#H*1/Math.cos(this.#W*Math.PI/180)}}class m{#i;#r;#s;#k;#j;#K;#$;#o;#h;#l;#q;#J;#Q;#tt;#et;#it;#rt;#st;#X;#nt;#m;#x;constructor(t,e,i,r,s,n,a){this.#i=t,this.#r=e,this.#s=i,this.#k=r,this.#j=s,this.#K=n,this.#$=a,this.#d(),this.#v(),this.#G(),this.#R(),this.#b()}setTextureSize(t,e){this.#r=t,this.#s=e,this.#at()}delete(){this.#i.deleteTexture(this.#m),this.#i.deleteBuffer(this.#X),this.#i.deleteFramebuffer(this.#x)}draw(e){this.#i.disable(this.#i.DEPTH_TEST),this.#i.enable(this.#i.BLEND),this.#i.blendFunc(this.#i.ONE,this.#i.ONE),this.#i.useProgram(this.#o),this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,this.#x),this.#i.viewport(0,0,this.#r,this.#s),this.#i.clear(this.#i.COLOR_BUFFER_BIT),this.#i.uniformMatrix4fv(this.#l,!1,e),this.#i.uniform1f(this.#Q,this.#K),this.#i.uniform2f(this.#tt,this.#r,this.#s),this.#$&&(this.#i.uniform1i(this.#st,1),this.#i.uniformMatrix4fv(this.#et,!1,t.inverse(e)));for(let i=0;i<this.#k.length;i++){const r=this.#k[i],s=t.dot(e,new Float32Array([r[0],r[1],0,1]));this.#i.uniform2f(this.#rt,s[0]/s[3],s[1]/s[3]),this.#i.uniform1f(this.#q,r[2]),this.#i.uniform2f(this.#J,r[0],r[1]),this.#i.uniform1f(this.#it,this.#j[i]),this.#i.bindBuffer(this.#i.ARRAY_BUFFER,this.#X),this.#i.enableVertexAttribArray(this.#h),this.#i.vertexAttribPointer(this.#h,2,this.#i.FLOAT,!1,0,0),this.#i.drawArrays(this.#i.TRIANGLE_STRIP,0,this.#nt)}}getTexture(){return this.#m}updatePointsAndDistances(t,e){this.#k=t,this.#j=e}#d(){this.#o=a(this.#i,s(this.#i,i(630)),n(this.#i,i(236)))}#v(){this.#h=this.#i.getAttribLocation(this.#o,"position"),this.#l=this.#i.getUniformLocation(this.#o,"mvpMatrix"),this.#q=this.#i.getUniformLocation(this.#o,"ui"),this.#J=this.#i.getUniformLocation(this.#o,"xi"),this.#Q=this.#i.getUniformLocation(this.#o,"p"),this.#tt=this.#i.getUniformLocation(this.#o,"framebufferSize"),this.#et=this.#i.getUniformLocation(this.#o,"mvpMatrixInverse"),this.#it=this.#i.getUniformLocation(this.#o,"pointRadius"),this.#rt=this.#i.getUniformLocation(this.#o,"xiImageSpace"),this.#st=this.#i.getUniformLocation(this.#o,"fasterPointRadius")}#G(){this.#X=o(this.#i,this.#i.ARRAY_BUFFER,new Float32Array([1,1,-1,1,1,-1,-1,-1])),this.#nt=4}#R(){this.#m=this.#i.createTexture(),this.#i.bindTexture(this.#i.TEXTURE_2D,this.#m),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_WRAP_S,this.#i.CLAMP_TO_EDGE),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_WRAP_T,this.#i.CLAMP_TO_EDGE),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_MAG_FILTER,this.#i.NEAREST),this.#i.texParameteri(this.#i.TEXTURE_2D,this.#i.TEXTURE_MIN_FILTER,this.#i.NEAREST),this.#at(),this.#i.bindTexture(this.#i.TEXTURE_2D,null)}#b(){this.#x=this.#i.createFramebuffer(),this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,this.#x),this.#i.framebufferTexture2D(this.#i.FRAMEBUFFER,this.#i.COLOR_ATTACHMENT0,this.#i.TEXTURE_2D,this.#m,0),this.#i.bindFramebuffer(this.#i.FRAMEBUFFER,null)}#at(){this.#i.bindTexture(this.#i.TEXTURE_2D,this.#m),this.#i.texImage2D(this.#i.TEXTURE_2D,0,e(this.#i)?this.#i.RGBA32F:this.#i.RGBA,this.#r,this.#s,0,this.#i.RGBA,this.#i.FLOAT,null)}}class x{#ot;#ht;#k;#j;#a;#w;#lt;#ft;#ut;constructor(t){this.#ot=t}init(t,e){this.#ht=e,this.#gt(t),this.#ct(),this.#lt=new u(t,this.#ht.width,this.#ht.height,this.#k,this.#j,this.#a),this.#ft=new m(t,Math.ceil(this.#ht.width*this.#ot.framebufferFactor),Math.ceil(this.#ht.height*this.#ot.framebufferFactor),this.#k,this.#j,this.#ot.p,this.#ot.pointRadius>0&&this.#ot.fasterPointRadius),this.#ut=new g(t,!this.#ot.fasterPointRadius&&this.#k.length==this.#j.length,this.#ot.opacity,this.#ot.valueToColor,this.#ot.valueToColor4,this.#w,this.#ot.averageThreshold,this.#ot.layerBlendingFactor,this.#ot.mapBlendingFactor)}resizeFramebuffer(){this.#ft.setTextureSize(Math.ceil(this.#ht.width*this.#ot.framebufferFactor),Math.ceil(this.#ht.height*this.#ot.framebufferFactor))}delete(){this.#lt.delete(),this.#ft.delete(),this.#ut.delete()}preRender(t){this.#lt.draw(t),this.#ft.draw(t)}render(t){this.#ut.draw(t,this.#lt.getTexture(),this.#ft.getTexture(),this.#ht.width,this.#ht.height)}updatePoints(t){this.#ot.points=t,this.#ct(),this.#lt.updatePointsAndDistances(this.#k,this.#j),this.#ft.updatePointsAndDistances(this.#k,this.#j)}#gt(t){const i=[];e(t)?i.push("EXT_color_buffer_float","EXT_float_blend"):i.push("OES_texture_float","WEBGL_color_buffer_float","EXT_float_blend");for(let e of i)if(!t.getExtension(e))throw"WebGL extension "+e+" not supported"}#ct(){this.#k=[],this.#j=[],this.#w=0;let t=1/0,e=-1/0;for(let i of this.#ot.points){const r=new c(i.lat,i.lon);this.#k.push([r.getX(),r.getY(),i.val]),this.#ot.pointRadius>0&&this.#j.push(r.meterInMercatorCoordinateUnits()*this.#ot.pointRadius),i.val<t&&(t=i.val),i.val>e&&(e=i.val)}t=t<this.#ot.minValue?t:this.#ot.minValue,e=e>this.#ot.maxValue?e:this.#ot.maxValue;for(let i of this.#k)i[2]=(i[2]-t)/(e-t),this.#w+=i[2];this.#w/=this.#k.length,this.#a=this.#ot.roi.map((t=>{const e=new c(t.lat,t.lon);return[e.getX(),e.getY()]}))}}function p(t){const e={layerId:"",opacity:.5,minValue:1/0,maxValue:-1/0,p:3,framebufferFactor:.3,points:[],roi:[],averageThreshold:0,valueToColor:"\n vec3 valueToColor(float value) {\n return vec3(max((value-0.5)*2.0, 0.0), 1.0 - 2.0*abs(value - 0.5), max((0.5-value)*2.0, 0.0));\n }\n ",valueToColor4:"\n vec4 valueToColor4(float value, float defaultOpacity) {\n return vec4(valueToColor(value), defaultOpacity);\n }\n ",pointRadius:0,fasterPointRadius:!1,layerBlendingFactor:WebGLRenderingContext.SRC_ALPHA,mapBlendingFactor:WebGLRenderingContext.ONE_MINUS_SRC_ALPHA};if("object"==typeof t)for(let i in t)e[i]=t[i];const i=new x(e);return{id:e.layerId,type:"custom",onAdd:function(t,e){i.init(e,t._canvas),this.resizeFramebuffer=()=>{i.resizeFramebuffer()},t.on("resize",this.resizeFramebuffer)},onRemove:function(t,e){i.delete(),t.off("resize",this.resizeFramebuffer)},prerender:function(t,e){i.preRender(e)},render:function(t,e){i.render(e)},updatePoints:function(t){i.updatePoints(t)}}}})(),r})()));