@deck.gl/aggregation-layers 9.0.7 → 9.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +2 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +2 -2
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +2 -1
- package/dist.min.js +1 -1
- package/package.json +4 -4
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen-grid-cell-layer.d.ts","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-cell-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,KAAK,EAAW,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAE,UAAU,EAAgB,gBAAgB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAI9F,OAAO,KAAK,EAAC,qBAAqB,EAAC,+BAA4B;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAclD,uDAAuD;AACvD,MAAM,MAAM,wBAAwB,CAAC,KAAK,GAAG,OAAO,IAAI,yBAAyB,CAAC,KAAK,CAAC,GACtF,UAAU,CAAC;AAEb,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,CAAC,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC5E,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,mBAAmB,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,KAAK,CAC9F,WAAW,GAAG,QAAQ,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CACzD;IACC,MAAM,CAAC,SAAS,SAAyB;IACzC,MAAM,CAAC,YAAY,kDAAgB;IAEnC,KAAK,EAAG;QACN,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,CAAC;IAEF,UAAU,IAAI;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,YAAY,EAAE,CAAA;KAAC;IAI/D,eAAe;IAYf,iBAAiB,CAAC,EAAC,WAAW,EAAC;;KAAA;IAK/B,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAe1C,IAAI,CAAC,EAAC,QAAQ,EAAC;;KAAA;IA2Bf,0BAA0B,CAAC,SAAS,KAAA,EAAE,EAAC,YAAY,EAAC;;KAAA;IAkBpD,SAAS,IAAI,KAAK;
|
|
1
|
+
{"version":3,"file":"screen-grid-cell-layer.d.ts","sourceRoot":"","sources":["../../src/screen-grid-layer/screen-grid-cell-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,KAAK,EAAW,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAE,UAAU,EAAgB,gBAAgB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAI9F,OAAO,KAAK,EAAC,qBAAqB,EAAC,+BAA4B;AAC/D,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAclD,uDAAuD;AACvD,MAAM,MAAM,wBAAwB,CAAC,KAAK,GAAG,OAAO,IAAI,yBAAyB,CAAC,KAAK,CAAC,GACtF,UAAU,CAAC;AAEb,8CAA8C;AAC9C,MAAM,MAAM,yBAAyB,CAAC,KAAK,IAAI,qBAAqB,CAAC,KAAK,CAAC,GAAG;IAC5E,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,mBAAmB,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,KAAK,CAC9F,WAAW,GAAG,QAAQ,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CACzD;IACC,MAAM,CAAC,SAAS,SAAyB;IACzC,MAAM,CAAC,YAAY,kDAAgB;IAEnC,KAAK,EAAG;QACN,KAAK,CAAC,EAAE,KAAK,CAAC;KACf,CAAC;IAEF,UAAU,IAAI;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,YAAY,EAAE,CAAA;KAAC;IAI/D,eAAe;IAYf,iBAAiB,CAAC,EAAC,WAAW,EAAC;;KAAA;IAK/B,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC;IAe1C,IAAI,CAAC,EAAC,QAAQ,EAAC;;KAAA;IA2Bf,0BAA0B,CAAC,SAAS,KAAA,EAAE,EAAC,YAAY,EAAC;;KAAA;IAkBpD,SAAS,IAAI,KAAK;IAuBlB,gBAAgB,IAAI,OAAO;IAe3B,eAAe,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,EAAE,WAAW,KAAA,GAAG,IAAI;CA2BpD"}
|
package/dist.min.js
CHANGED
|
@@ -296,7 +296,7 @@ discard;
|
|
|
296
296
|
fragColor = vColor;
|
|
297
297
|
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
298
298
|
}
|
|
299
|
-
`;var Li=[0,0,0,0],Fi=[0,255,0,255],wi=["minColor","maxColor","colorRange","colorDomain"],Ii={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:D},Dt=class extends et.Layer{getShaders(){return{vs:Ie,fs:Re,modules:[et.picking]}}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t);let{oldProps:e,props:o,changeFlags:i}=t,r=this.getAttributeManager();o.numInstances!==e.numInstances?r.invalidateAll():e.cellSizePixels!==o.cellSizePixels&&r.invalidate("instancePositions"),this._updateUniforms(e,o,i)}draw({uniforms:t}){let{parameters:e,maxTexture:o}=this.props,i=this.props.minColor||Li,r=this.props.maxColor||Fi,s=this.props.colorDomain||[1,0],a=this.state.model;a.setUniforms(t),a.setBindings({maxTexture:o}),a.setUniforms({minColor:i,maxColor:r,colorDomain:s}),a.setParameters({depthWriteEnabled:!1,...e}),a.draw(this.context.renderPass)}calculateInstancePositions(t,{numInstances:e}){let{width:o,height:i}=this.context.viewport,{cellSizePixels:r}=this.props,s=Math.ceil(o/r),{value:a,size:l}=t;for(let c=0;c<e;c++){let g=c%s,f=Math.floor(c/s);a[c*l+0]=g*r/o*2-1,a[c*l+1]=1-f*r/i*2,a[c*l+2]=0}}_getModel(){return new Ot.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot.Geometry({topology:"triangle-list",attributes:{positions:new Float32Array([0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0])}})})}_shouldUseMinMax(){let{minColor:t,maxColor:e,colorDomain:o,colorRange:i}=this.props;return t||e?(et.log.deprecated("ScreenGridLayer props: minColor and maxColor","colorRange, colorDomain")(),!0):!(o||i)}_updateUniforms(t,e,o){let i=this.state.model;if(wi.some(r=>t[r]!==e[r])&&i.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),t.colorRange!==e.colorRange&&i.setUniforms({colorRange:z(e.colorRange)}),t.cellMarginPixels!==e.cellMarginPixels||t.cellSizePixels!==e.cellSizePixels||o.viewportChanged){let{width:r,height:s}=this.context.viewport,{cellSizePixels:a,cellMarginPixels:l}=this.props,c=a>l?l:0,g=new Float32Array([(a-c)/r*2,-(a-c)/s*2,1]);i.setUniforms({cellScale:g})}}},tt=Dt;(()=>{Dt.layerName="ScreenGridCellLayer"})(),(()=>{Dt.defaultProps=Ii})();var to=M(E(),1);var ot=M(E(),1);function Be(n,t){let e={};for(let o in n)t.includes(o)||(e[o]=n[o]);return e}var oe=class extends ot.CompositeLayer{initializeAggregationLayer(t){super.initializeState(this.context),this.setState({ignoreProps:Be(this.constructor._propTypes,t.data.props),dimensions:t})}updateState(t){super.updateState(t);let{changeFlags:e}=t;if(e.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(t){this.setState({changedAttributes:t})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:t,mousePosition:e,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:t,mousePosition:e,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(t){}isAggregationDirty(t,e={}){let{props:o,oldProps:i,changeFlags:r}=t,{compareAll:s=!1,dimension:a}=e,{ignoreProps:l}=this.state,{props:c,accessors:g=[]}=a,{updateTriggersChanged:f}=r;if(r.dataChanged)return!0;if(f){if(f.all)return!0;for(let d of g)if(f[d])return!0}if(s)return r.extensionsChanged?!0:(0,ot._compareProps)({oldProps:i,newProps:o,ignoreProps:l,propTypes:this.constructor._propTypes});for(let d of c)if(o[d]!==i[d])return!0;return!1}isAttributeChanged(t){let{changedAttributes:e}=this.state;return t?e&&e[t]!==void 0:!Ri(e)}_getAttributeManager(){return new ot.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}},P=oe;(()=>{oe.layerName="AggregationLayer"})();function Ri(n){let t=!0;for(let e in n){t=!1;break}return t}var We=M(E(),1);function Lt(n,t,e){let o=e;return o.domain=()=>n,o.range=()=>t,o}function Ue(n,t){return Lt(n,t,o=>ki(n,t,o))}function Bi(n,t){return Lt(n,t,o=>ji(n,t,o))}function Ui(n,t){let e=n.sort(ze),o=0,i=Math.max(1,t.length),r=new Array(i-1);for(;++o<i;)r[o-1]=Wi(e,o/i);let s=a=>Gi(r,t,a);return s.thresholds=()=>r,Lt(n,t,s)}function ze(n,t){return n-t}function Wi(n,t){let e=n.length;if(t<=0||e<2)return n[0];if(t>=1)return n[e-1];let o=(e-1)*t,i=Math.floor(o),r=n[i],s=n[i+1];return r+(s-r)*(o-i)}function zi(n,t){let e=0,o=n.length;for(;e<o;){let i=e+o>>>1;ze(n[i],t)>0?o=i:e=i+1}return e}function Gi(n,t,e){return t[zi(n,e)]}function Hi(n,t,e,o){let i=`${o}`,r=t.get(i);return r===void 0&&(r=n.push(o),t.set(i,r)),e[(r-1)%e.length]}function Vi(n,t){let e=new Map,o=[];for(let r of n){let s=`${r}`;e.has(s)||e.set(s,o.push(r))}return Lt(n,t,r=>Hi(o,e,t,r))}function ki(n,t,e){let o=n[1]-n[0];if(o<=0)return We.log.warn("quantizeScale: invalid domain, returning range[0]")(),t[0];let i=o/t.length,r=Math.floor((e-n[0])/i),s=Math.max(Math.min(r,t.length-1),0);return t[s]}function ji(n,t,e){return(e-n[0])/(n[1]-n[0])*(t[1]-t[0])+t[0]}function Ge(n){return n!=null}function Xi(n){let t=[];return n.forEach(e=>{!t.includes(e)&&Ge(e)&&t.push(e)}),t}function He(n,t){return(typeof t=="function"?n.map(t):n).filter(Ge)}function Ve(n,t){return He(n,t)}function ke(n,t){return Xi(He(n,t))}function je(n,t,e){return Math.max(t,Math.min(e,n))}function Xe(n){switch(n){case"quantize":return Ue;case"linear":return Bi;case"quantile":return Ui;case"ordinal":return Vi;default:return Ue}}var Ye=n=>n.length,qi=3402823466e29,$e=n=>n.points,Ke=n=>n.index,qe=(n,t)=>n<t?-1:n>t?1:n>=t?0:NaN,Yi={getValue:Ye,getPoints:$e,getIndex:Ke,filterData:null},F=class{constructor(t=[],e=Yi){this.aggregatedBins=this.getAggregatedBins(t,e),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(t,e){let{getValue:o=Ye,getPoints:i=$e,getIndex:r=Ke,filterData:s}=e,a=typeof s=="function",l=t.length,c=[],g=0;for(let f=0;f<l;f++){let d=t[f],p=i(d),x=r(d),h=a?p.filter(s):p;d.filteredPoints=a?h:null;let A=h.length?o(h):null;A!=null&&(c[g]={i:Number.isFinite(x)?x:f,value:A,counts:h.length},g++)}return c}_percentileToIndex(t){let e=this.sortedBins.length;if(e<2)return[0,0];let[o,i]=t.map(a=>je(a,0,100)),r=Math.ceil(o/100*(e-1)),s=Math.floor(i/100*(e-1));return[r,s]}getBinMap(){let t={};for(let e of this.aggregatedBins)t[e.i]=e;return t}_updateMinMaxValues(){let t=0,e=0,o=qi,i=0;for(let r of this.aggregatedBins)t=t>r.counts?t:r.counts,e=e>r.value?e:r.value,o=o<r.value?o:r.value,i+=r.counts;this.maxCount=t,this.maxValue=e,this.minValue=o,this.totalCount=i}getValueRange(t){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((i,r)=>qe(i.value,r.value))),!this.sortedBins.length)return[];let e=0,o=this.sortedBins.length-1;if(Array.isArray(t)){let i=this._percentileToIndex(t);e=i[0],o=i[1]}return[this.sortedBins[e].value,this.sortedBins[o].value]}getValueDomainByScale(t,[e=0,o=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((r,s)=>qe(r.value,s.value))),!this.sortedBins.length)return[];let i=this._percentileToIndex([e,o]);return this._getScaleDomain(t,i)}_getScaleDomain(t,[e,o]){let i=this.sortedBins;switch(t){case"quantize":case"linear":return[i[e].value,i[o].value];case"quantile":return Ve(i.slice(e,o+1),r=>r.value);case"ordinal":return ke(i,r=>r.value);default:return[i[e].value,i[o].value]}}};var Je=M(E(),1);var G=M(E(),1),Ze=6378e3;function Ft(n){return Number.isFinite(n)?n:0}function wt(n,t){let e=n.positions.value,o=1/0,i=-1/0,r=1/0,s=-1/0,a,l;for(let g=0;g<t;g++)l=e[g*3],a=e[g*3+1],o=a<o?a:o,i=a>i?a:i,r=l<r?l:r,s=l>s?l:s;return{xMin:Ft(r),xMax:Ft(s),yMin:Ft(o),yMax:Ft(i)}}function $i(n,t,e,o){let{width:i,height:r}=o,s=e===G.COORDINATE_SYSTEM.CARTESIAN?[-i/2,-r/2]:[-180,-90];G.log.assert(e===G.COORDINATE_SYSTEM.CARTESIAN||e===G.COORDINATE_SYSTEM.LNGLAT||e===G.COORDINATE_SYSTEM.DEFAULT);let{xMin:a,yMin:l}=n;return[-1*(Qe(a-s[0],t.xOffset)+s[0]),-1*(Qe(l-s[1],t.yOffset)+s[1])]}function Qe(n,t){let e=n<0?-1:1,o=e<0?Math.abs(n)+t:Math.abs(n);return o=Math.floor(o/t)*t,o*e}function ie(n,t,e=!0){if(!e)return{xOffset:t,yOffset:t};let{yMin:o,yMax:i}=n,r=(o+i)/2;return Ki(t,r)}function It(n,t,e,o){let i=ie(n,t,o!==G.COORDINATE_SYSTEM.CARTESIAN),r=$i(n,i,o,e),{xMin:s,yMin:a,xMax:l,yMax:c}=n,g=l-s+i.xOffset,f=c-a+i.yOffset,d=Math.ceil(g/i.xOffset),p=Math.ceil(f/i.yOffset);return{gridOffset:i,translation:r,width:g,height:f,numCol:d,numRow:p}}function Ki(n,t){let e=Qi(n),o=Zi(t,n);return{yOffset:e,xOffset:o}}function Qi(n){return n/Ze*(180/Math.PI)}function Zi(n,t){return t/Ze*(180/Math.PI)/Math.cos(n*Math.PI/180)}function it(n,t){let e=Ji(n,t),o=tr(e);return{gridHash:e.gridHash,gridOffset:e.gridOffset,data:o}}function Ji(n,t){let{data:e=[],cellSize:o}=n,{attributes:i,viewport:r,projectPoints:s,numInstances:a}=t,l=i.positions.value,{size:c}=i.positions.getAccessor(),g=t.boundingBox||er(i.positions,a),f=t.posOffset||[180,90],d=t.gridOffset||ie(g,o);if(d.xOffset<=0||d.yOffset<=0)return{gridHash:{},gridOffset:d,offsets:[0,0]};let{width:p,height:x}=r,h=Math.ceil(p/d.xOffset),A=Math.ceil(x/d.yOffset),S={},{iterable:y,objectInfo:_}=(0,Je.createIterable)(e),b=new Array(3);for(let O of y){_.index++,b[0]=l[_.index*c],b[1]=l[_.index*c+1],b[2]=c>=3?l[_.index*c+2]:0;let[B,mt]=s?r.project(b):b;if(Number.isFinite(B)&&Number.isFinite(mt)){let k=Math.floor((mt+f[1])/d.yOffset),j=Math.floor((B+f[0])/d.xOffset);if(!s||j>=0&&j<h&&k>=0&&k<A){let X=`${k}-${j}`;S[X]=S[X]||{count:0,points:[],lonIdx:j,latIdx:k},S[X].count+=1,S[X].points.push({source:O,index:_.index})}}}return{gridHash:S,gridOffset:d,offsets:[f[0]*-1,f[1]*-1]}}function tr({gridHash:n,gridOffset:t,offsets:e}){let o=new Array(Object.keys(n).length),i=0;for(let r in n){let s=r.split("-"),a=parseInt(s[0],10),l=parseInt(s[1],10),c=i++;o[c]={index:c,position:[e[0]+t.xOffset*l,e[1]+t.yOffset*a],...n[r]}}return o}function er(n,t){let e=n.value,{size:o}=n.getAccessor(),i=1/0,r=-1/0,s=1/0,a=-1/0,l,c;for(let g=0;g<t;g++)c=e[g*o],l=e[g*o+1],Number.isFinite(c)&&Number.isFinite(l)&&(i=l<i?l:i,r=l>r?l:r,s=c<s?c:s,a=c>a?c:a);return{xMin:s,xMax:a,yMin:i,yMax:r}}var re=class extends P{initializeAggregationLayer({dimensions:t}){super.initializeAggregationLayer(t),this.setState({layerData:{},gpuGridAggregator:new C(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:it})}updateState(t){super.updateState(t),this.updateAggregationState(t);let{aggregationDataDirty:e,aggregationWeightsDirty:o,gpuAggregation:i}=this.state;if(this.getNumInstances()<=0)return;let r=!1;(e||i&&o)&&(this._updateAggregation(t),r=!0),!i&&(e||o)&&(this._updateWeightBins(),this._uploadAggregationResults(),r=!0),this.setState({aggregationDirty:r})}finalizeState(t){let{count:e}=this.state.weights;e&&e.aggregationBuffer&&e.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(t)}updateShaders(t){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(t)}updateAggregationState(t){to.log.assert(!1)}allocateResources(t,e){if(this.state.numRow!==t||this.state.numCol!==e){let o=e*t*4*4,{weights:i}=this.state;for(let r in i){let s=i[r];s.aggregationBuffer&&s.aggregationBuffer.delete(),s.aggregationBuffer=this.context.device.createBuffer({byteLength:o,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:t,maxMinData:e,maxData:o,minData:i}){let{count:r}=this.state.weights;r&&(r.aggregationData=t,r.maxMinData=e,r.maxData=o,r.minData=i)}_updateAggregation(t){let{cpuGridAggregator:e,gpuGridAggregator:o,gridOffset:i,posOffset:r,translation:s=[0,0],scaling:a=[0,0,0],boundingBox:l,projectPoints:c,gpuAggregation:g,numCol:f,numRow:d}=this.state,{props:p}=t,{viewport:x}=this.context,h=this.getAttributes(),A=this.getNumInstances();if(g){let{weights:S}=this.state;o.run({weights:S,cellSize:[i.xOffset,i.yOffset],numCol:f,numRow:d,translation:s,scaling:a,vertexCount:A,projectPoints:c,attributes:h,moduleSettings:this.getModuleSettings()})}else{let S=e(p,{gridOffset:i,projectPoints:c,attributes:h,viewport:x,posOffset:r,boundingBox:l});this.setState({layerData:S})}}_updateWeightBins(){let{getValue:t}=this.state,e=new F(this.state.layerData.data||[],{getValue:t});this.setState({sortedBins:e})}_uploadAggregationResults(){let{numCol:t,numRow:e}=this.state,{data:o}=this.state.layerData,{aggregatedBins:i,minValue:r,maxValue:s,totalCount:a}=this.state.sortedBins,l=4,c=t*e*l,g=new Float32Array(c).fill(0);for(let x of i){let{lonIdx:h,latIdx:A}=o[x.i],{value:S,counts:y}=x,_=(h+A*t)*l;g[_]=S,g[_+l-1]=y}let f=new Float32Array([s,0,0,r]),d=new Float32Array([s,0,0,a]),p=new Float32Array([r,0,0,a]);this.updateResults({aggregationData:g,maxMinData:f,maxData:d,minData:p})}},w=re;(()=>{re.layerName="GridAggregationLayer"})();var or={...tt.defaultProps,getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},eo="positions",ir={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Rt=class extends w{initializeState(){super.initializeAggregationLayer({dimensions:ir,getCellSize:o=>o.cellSizePixels});let t={count:{size:1,operation:T.SUM,needMax:!0,maxTexture:Z(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:t,subLayerData:{attributes:{}},maxTexture:t.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[eo]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:t}){return this.state.supported&&t.somethingChanged}updateState(t){super.updateState(t)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:t,numRow:e,numCol:o,weights:i}=this.state,{updateTriggers:r}=this.props,{aggregationBuffer:s}=i.count,a=this.getSubLayerClass("cells",tt);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:r}),{data:{attributes:{instanceCounts:s}},maxTexture:t,numInstances:e*o})}finalizeState(t){super.finalizeState(t);let{aggregationBuffer:e,maxBuffer:o,maxTexture:i}=this.state;e?.delete(),o?.delete(),i?.delete()}getPickingInfo({info:t}){let{index:e}=t;if(e>=0){let{gpuGridAggregator:o,gpuAggregation:i,weights:r}=this.state,s=i?o.getData("count"):r.count;t.object=C.getAggregationData({pixelIndex:e,...s})}return t}updateResults({aggregationData:t,maxData:e}){let{count:o}=this.state.weights;o.aggregationData=t,o.aggregationBuffer.write(t),o.maxData=e,o.maxTexture.setImageData({data:e})}updateAggregationState(t){let e=t.props.cellSizePixels,o=t.oldProps.cellSizePixels!==e,{viewportChanged:i}=t.changeFlags,r=t.props.gpuAggregation;this.state.gpuAggregation!==t.props.gpuAggregation&&r&&!C.isSupported(this.context.device)&&(oo.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),r=!1);let s=r!==this.state.gpuAggregation;this.setState({gpuAggregation:r});let a=this.isAttributeChanged(eo),{dimensions:l}=this.state,{data:c,weights:g}=l,f=a||s||i||this.isAggregationDirty(t,{compareAll:r,dimension:c}),d=this.isAggregationDirty(t,{dimension:g});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:d});let{viewport:p}=this.context;if(i||o){let{width:x,height:h}=p,A=Math.ceil(x/e),S=Math.ceil(h/e);this.allocateResources(S,A),this.setState({scaling:[x/2,-h/2,1],gridOffset:{xOffset:e,yOffset:e},width:x,height:h,numCol:A,numRow:S})}d&&this._updateAccessors(t),(f||d)&&this._resetResults()}_updateAccessors(t){let{getWeight:e,aggregation:o,data:i}=t.props,{count:r}=this.state.weights;r&&(r.getWeight=e,r.operation=T[o]),this.setState({getValue:Q(o,e,{data:i})})}_resetResults(){let{count:t}=this.state.weights;t&&(t.aggregationData=null)}},St=Rt;(()=>{Rt.layerName="ScreenGridLayer"})(),(()=>{Rt.defaultProps=or})();var ao=M($(),1);function io(){}var ro=["getBins","getDomain","getScaleFunc"],no=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],rr=n=>n.cellSize,I=class{constructor(t){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=t.getCellSize||rr,this._getAggregator=t.getAggregator,this._addDimension(t.dimensions||no)}static defaultDimensions(){return no}updateState(t,e){let{oldProps:o,props:i,changeFlags:r}=t;this.updateGetValueFuncs(o,i,r);let s=this.needsReProjectPoints(o,i,r),a=!1;return r.dataChanged||s?(this.getAggregatedData(i,e),a=!0):((this.getDimensionChanges(o,i,r)||[]).forEach(c=>typeof c=="function"&&c()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(t){this.state={...this.state,...t}}setDimensionState(t,e){this.setState({dimensions:{...this.state.dimensions,[t]:{...this.state.dimensions[t],...e}}})}normalizeResult(t={}){return t.hexagons?{data:t.hexagons,...t}:t.layerData?{data:t.layerData,...t}:t}getAggregatedData(t,e){let i=this._getAggregator(t)(t,e);this.setState({layerData:this.normalizeResult(i)}),this.changeFlags={layerData:!0},this.getSortedBins(t)}updateGetValueFuncs(t,e,o){for(let i in this.dimensionUpdaters){let{value:r,weight:s,aggregation:a}=this.dimensionUpdaters[i].getBins.triggers,l=e[r.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[i].getBins,t,e,o)&&(l?l=Me(l,{data:e.data}):l=Q(e[a.prop],e[s.prop],{data:e.data})),l&&this.setDimensionState(i,{getValue:l})}}needsReProjectPoints(t,e,o){return this._getCellSize(t)!==this._getCellSize(e)||this._getAggregator(t)!==this._getAggregator(e)||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPosition)}addDimension(t){this._addDimension(t)}_addDimension(t=[]){t.forEach(e=>{let{key:o}=e;this.dimensionUpdaters[o]=this.getDimensionUpdaters(e),this.state.dimensions[o]={getValue:null,domain:null,sortedBins:null,scaleFunc:io}})}getDimensionUpdaters({key:t,accessor:e,pickingInfo:o,getBins:i,getDomain:r,getScaleFunc:s,nullValue:a}){return{key:t,accessor:e,pickingInfo:o,getBins:{updater:this.getDimensionSortedBins.bind(this),...i},getDomain:{updater:this.getDimensionValueDomain.bind(this),...r},getScaleFunc:{updater:this.getDimensionScale.bind(this),...s},attributeAccessor:this.getSubLayerDimensionAttribute(t,a)}}needUpdateDimensionStep(t,e,o,i){return Object.values(t.triggers).some(r=>r.updateTrigger?i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged[r.updateTrigger]):e[r.prop]!==o[r.prop])}getDimensionChanges(t,e,o){let i=[];for(let r in this.dimensionUpdaters){let s=ro.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[r][a],t,e,o));s&&i.push(this.dimensionUpdaters[r][s].updater.bind(this,e,this.dimensionUpdaters[r]))}return i.length?i:null}getUpdateTriggers(t){let e=t.updateTriggers||{},o={};for(let i in this.dimensionUpdaters){let{accessor:r}=this.dimensionUpdaters[i];o[r]={},ro.forEach(s=>{Object.values(this.dimensionUpdaters[i][s].triggers).forEach(({prop:a,updateTrigger:l})=>{if(l){let c=e[l];typeof c=="object"&&!Array.isArray(c)?Object.assign(o[r],c):c!==void 0&&(o[r][a]=c)}else o[r][a]=t[a]})})}return o}getSortedBins(t){for(let e in this.dimensionUpdaters)this.getDimensionSortedBins(t,this.dimensionUpdaters[e])}getDimensionSortedBins(t,e){let{key:o}=e,{getValue:i}=this.state.dimensions[o],r=new F(this.state.layerData.data||[],{getValue:i,filterData:t._filterData});this.setDimensionState(o,{sortedBins:r}),this.getDimensionValueDomain(t,e)}getDimensionValueDomain(t,e){let{getDomain:o,key:i}=e,{triggers:{lowerPercentile:r,upperPercentile:s,scaleType:a}}=o,l=this.state.dimensions[i].sortedBins.getValueDomainByScale(t[a.prop],[t[r.prop],t[s.prop]]);this.setDimensionState(i,{valueDomain:l}),this.getDimensionScale(t,e)}getDimensionScale(t,e){let{key:o,getScaleFunc:i,getDomain:r}=e,{domain:s,range:a}=i.triggers,{scaleType:l}=r.triggers,{onSet:c}=i,g=t[a.prop],f=t[s.prop]||this.state.dimensions[o].valueDomain,p=Xe(l&&t[l.prop])(f,g);typeof c=="object"&&typeof t[c.props]=="function"&&t[c.props](p.domain()),this.setDimensionState(o,{scaleFunc:p})}getSubLayerDimensionAttribute(t,e){return o=>{let{sortedBins:i,scaleFunc:r}=this.state.dimensions[t],s=i.binMap[o.index];if(s&&s.counts===0)return e;let a=s&&s.value,l=r.domain();return a>=l[0]&&a<=l[l.length-1]?r(a):e}}getSubLayerAccessors(t){let e={};for(let o in this.dimensionUpdaters){let{accessor:i}=this.dimensionUpdaters[o];e[i]=this.getSubLayerDimensionAttribute(t,o)}return e}getPickingInfo({info:t}){let e=t.picked&&t.index>-1,o=null;if(e){let i=this.state.layerData.data[t.index],r={};for(let s in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[s],{sortedBins:l}=this.state.dimensions[s],c=l.binMap[i.index]&&l.binMap[i.index].value;r[a]=c}o=Object.assign(r,i,{points:i.filteredPoints||i.points})}return t.picked=Boolean(o),t.object=o,t}getAccessor(t){return this.dimensionUpdaters.hasOwnProperty(t)?this.dimensionUpdaters[t].attributeAccessor:io}};function so(){}var nr={colorDomain:null,colorRange:D,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:so,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:so,gridAggregator:it,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},Bt=class extends P{initializeState(){let t=new I({getAggregator:o=>o.gridAggregator,getCellSize:o=>o.cellSize});this.state={cpuAggregator:t,aggregatorState:t.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(t){super.updateState(t),this.setState({aggregatorState:this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:t,extruded:e,cellSize:o,coverage:i,material:r,transitions:s}=this.props,{cpuAggregator:a}=this.state,l=this.getSubLayerClass("grid-cell",ao.GridCellLayer),c=this._getSublayerUpdateTriggers();return new l({cellSize:o,coverage:i,material:r,elevationScale:t,extruded:e,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:s&&{getFillColor:s.getColorValue||s.getColorWeight,getElevation:s.getElevationValue||s.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:c}),{data:a.state.layerData.data})}},H=Bt;(()=>{Bt.layerName="CPUGridLayer"})(),(()=>{Bt.defaultProps=nr})();var uo=M(E(),1),go=M($(),1);var rt=Math.PI/3,sr=[0,rt,2*rt,3*rt,4*rt,5*rt];function ar(n){return n[0]}function lr(n){return n[1]}function ne(){var n=0,t=0,e=1,o=1,i=ar,r=lr,s,a,l;function c(f){var d={},p=[],x,h=f.length;for(x=0;x<h;++x)if(!(isNaN(S=+i.call(null,A=f[x],x,f))||isNaN(y=+r.call(null,A,x,f)))){var A,S,y,_=Math.round(y=y/l),b=Math.round(S=S/a-(_&1)/2),O=y-_;if(Math.abs(O)*3>1){var B=S-b,mt=b+(S<b?-1:1)/2,k=_+(y<_?-1:1),j=S-mt,X=y-k;B*B+O*O>j*j+X*X&&(b=mt+(_&1?1:-1)/2,_=k)}var me=b+"-"+_,ht=d[me];ht?ht.push(A):(p.push(ht=d[me]=[A]),ht.x=(b+(_&1)/2)*a,ht.y=_*l)}return p}function g(f){var d=0,p=0;return sr.map(function(x){var h=Math.sin(x)*f,A=-Math.cos(x)*f,S=h-d,y=A-p;return d=h,p=A,[S,y]})}return c.hexagon=function(f){return"m"+g(f==null?s:+f).join("l")+"z"},c.centers=function(){for(var f=[],d=Math.round(t/l),p=Math.round(n/a),x=d*l;x<o+s;x+=l,++d)for(var h=p*a+(d&1)*a/2;h<e+a/2;h+=a)f.push([h,x]);return f},c.mesh=function(){var f=g(s).slice(0,4).join("l");return c.centers().map(function(d){return"M"+d+"m"+f}).join("")},c.x=function(f){return arguments.length?(i=f,c):i},c.y=function(f){return arguments.length?(r=f,c):r},c.radius=function(f){return arguments.length?(s=+f,a=s*2*Math.sin(rt),l=s*1.5,c):s},c.size=function(f){return arguments.length?(n=t=0,e=+f[0],o=+f[1],c):[e-n,o-t]},c.extent=function(f){return arguments.length?(n=+f[0][0],t=+f[0][1],e=+f[1][0],o=+f[1][1],c):[[n,t],[e,o]]},c.radius(1)}var Ut=M(E(),1);function lo(n,t){let{data:e,radius:o}=n,{viewport:i,attributes:r}=t,s=e.length?cr(e,t):null,a=ur(o,i,s),l=[],{iterable:c,objectInfo:g}=(0,Ut.createIterable)(e),f=r.positions.value,{size:d}=r.positions.getAccessor();for(let h of c){g.index++;let A=g.index*d,S=[f[A],f[A+1]];Number.isFinite(S[0])&&Number.isFinite(S[1])?l.push({screenCoord:i.projectFlat(S),source:h,index:g.index}):Ut.log.warn("HexagonLayer: invalid position")()}return{hexagons:ne().radius(a).x(h=>h.screenCoord[0]).y(h=>h.screenCoord[1])(l).map((h,A)=>({position:i.unprojectFlat([h.x,h.y]),points:h,index:A})),radiusCommon:a}}function cr(n,t){let{attributes:e}=t,o=e.positions.value,{size:i}=e.positions.getAccessor(),r=1/0,s=1/0,a=-1/0,l=-1/0,c;for(c=0;c<i*n.length;c+=i){let g=o[c],f=o[c+1];Number.isFinite(g)&&Number.isFinite(f)&&(r=Math.min(g,r),a=Math.max(g,a),s=Math.min(f,s),l=Math.max(f,l))}return[r,s,a,l].every(Number.isFinite)?[(r+a)/2,(s+l)/2]:null}function ur(n,t,e){let{unitsPerMeter:o}=t.getDistanceScales(e);return n*o[0]}function co(){}var gr={colorDomain:null,colorRange:D,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:co,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:co,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:lo,getPosition:{type:"accessor",value:n=>n.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},Wt=class extends P{initializeState(){let t=new I({getAggregator:o=>o.hexagonAggregator,getCellSize:o=>o.radius});this.state={cpuAggregator:t,aggregatorState:t.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(t){if(super.updateState(t),t.changeFlags.propsOrDataChanged){let e=this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==e.layerData){let{hexagonVertices:o}=e.layerData||{};this.setState({vertices:o&&this.convertLatLngToMeterOffset(o)})}this.setState({aggregatorState:e})}}convertLatLngToMeterOffset(t){let{viewport:e}=this.context;if(Array.isArray(t)&&t.length===6){let o=t[0],i=t[3],r=[(o[0]+i[0])/2,(o[1]+i[1])/2],s=e.projectFlat(r),{metersPerUnit:a}=e.getDistanceScales(r);return t.map(c=>{let g=e.projectFlat(c);return[(g[0]-s[0])*a[0],(g[1]-s[1])*a[1]]})}return uo.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:t,extruded:e,coverage:o,material:i,transitions:r}=this.props,{aggregatorState:s,vertices:a}=this.state,l=this.getSubLayerClass("hexagon-cell",go.ColumnLayer),c=this._getSublayerUpdateTriggers(),g=a?{vertices:a,radius:1}:{radius:s.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new l({...g,diskResolution:6,elevationScale:t,extruded:e,coverage:o,material:i,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:r&&{getFillColor:r.getColorValue||r.getColorWeight,getElevation:r.getElevationValue||r.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:c}),{data:s.layerData.data})}},At=Wt;(()=>{Wt.layerName="HexagonLayer"})(),(()=>{Wt.defaultProps=gr})();var jt=M($(),1);var Uo=M(E(),1);var v=.16666666666666666,u={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},nt=[u.W,u.SW,u.S],st=[u.S,u.SE,u.E],at=[u.E,u.NE,u.N],lt=[u.NW,u.W,u.N],ct=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5]],ut=[[-v,-.5],[v,-.5],[.5,-v],[.5,v]],gt=[[.5,-v],[.5,v],[v,.5],[-v,.5]],ft=[[-.5,v],[-.5,-v],[v,.5],[-v,.5]],fo=[u.W,u.SW,u.SE,u.E],po=[u.S,u.SE,u.NE,u.N],mo=[u.NW,u.W,u.E,u.NE],ho=[u.NW,u.SW,u.S,u.N],xo=[[-.5,v],[-.5,-v],[.5,-v],[.5,v]],vo=[[-v,-.5],[v,-.5],[v,.5],[-v,.5]],fr=[u.NW,u.SW,u.SE,u.NE],So=[u.NW,u.SW,u.SE,u.E,u.N],Ao=[u.W,u.SW,u.SE,u.NE,u.N],yo=[u.NW,u.W,u.S,u.SE,u.NE],_o=[u.NW,u.SW,u.S,u.E,u.NE],bo=[u.NW,u.W,[.5,-v],[.5,v],u.N],Mo=[[-v,-.5],[v,-.5],u.E,u.NE,u.N],To=[[-.5,v],[-.5,-v],u.S,u.SE,u.E],Co=[u.W,u.SW,u.S,[v,.5],[-v,.5]],Eo=[u.NW,u.W,[-v,-.5],[v,-.5],u.N],Po=[[-.5,v],[-.5,-v],u.E,u.NE,u.N],No=[u.S,u.SE,u.E,[v,.5],[-v,.5]],Do=[u.W,u.SW,u.S,[.5,-v],[.5,v]],Oo=[u.W,u.SW,u.SE,u.E,[v,.5],[-v,.5]],Lo=[[-.5,v],[-.5,-v],u.S,u.SE,u.NE,u.N],Fo=[u.NW,u.W,[-v,-.5],[v,-.5],u.E,u.NE],wo=[u.NW,u.SW,u.S,[.5,-v],[.5,v],u.N],dt=[u.W,u.SW,u.S,u.E,u.NE,u.N],pt=[u.NW,u.W,u.S,u.SE,u.E,u.N],zt=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5],u.E,u.NE,u.N],Gt=[u.W,u.SW,u.S,[.5,-v],[.5,v],[v,.5],[-v,.5]],Ht=[u.NW,u.W,[-v,-.5],[v,-.5],[.5,-v],[.5,v],u.N],Vt=[[-.5,v],[-.5,-v],u.S,u.SE,u.E,[v,.5],[-v,.5]],Io=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5],[.5,-v],[.5,v],[v,.5],[-v,.5]],Ro={0:[],1:[[u.W,u.S]],2:[[u.S,u.E]],3:[[u.W,u.E]],4:[[u.N,u.E]],5:{0:[[u.W,u.S],[u.N,u.E]],1:[[u.W,u.N],[u.S,u.E]]},6:[[u.N,u.S]],7:[[u.W,u.N]],8:[[u.W,u.N]],9:[[u.N,u.S]],10:{0:[[u.W,u.N],[u.S,u.E]],1:[[u.W,u.S],[u.N,u.E]]},11:[[u.N,u.E]],12:[[u.W,u.E]],13:[[u.S,u.E]],14:[[u.W,u.S]],15:[]};function m(n){return parseInt(n,4)}var Bo={[m("0000")]:[],[m("2222")]:[],[m("2221")]:[nt],[m("2212")]:[st],[m("2122")]:[at],[m("1222")]:[lt],[m("0001")]:[nt],[m("0010")]:[st],[m("0100")]:[at],[m("1000")]:[lt],[m("2220")]:[ct],[m("2202")]:[ut],[m("2022")]:[gt],[m("0222")]:[ft],[m("0002")]:[ct],[m("0020")]:[ut],[m("0200")]:[gt],[m("2000")]:[ft],[m("0011")]:[fo],[m("0110")]:[po],[m("1100")]:[mo],[m("1001")]:[ho],[m("2211")]:[fo],[m("2112")]:[po],[m("1122")]:[mo],[m("1221")]:[ho],[m("2200")]:[xo],[m("2002")]:[vo],[m("0022")]:[xo],[m("0220")]:[vo],[m("1111")]:[fr],[m("1211")]:[So],[m("2111")]:[Ao],[m("1112")]:[yo],[m("1121")]:[_o],[m("1011")]:[So],[m("0111")]:[Ao],[m("1110")]:[yo],[m("1101")]:[_o],[m("1200")]:[bo],[m("0120")]:[Mo],[m("0012")]:[To],[m("2001")]:[Co],[m("1022")]:[bo],[m("2102")]:[Mo],[m("2210")]:[To],[m("0221")]:[Co],[m("1002")]:[Eo],[m("2100")]:[Po],[m("0210")]:[No],[m("0021")]:[Do],[m("1220")]:[Eo],[m("0122")]:[Po],[m("2012")]:[No],[m("2201")]:[Do],[m("0211")]:[Oo],[m("2110")]:[Lo],[m("1102")]:[Fo],[m("1021")]:[wo],[m("2011")]:[Oo],[m("0112")]:[Lo],[m("1120")]:[Fo],[m("1201")]:[wo],[m("2101")]:[dt],[m("0121")]:[dt],[m("1012")]:[pt],[m("1210")]:[pt],[m("0101")]:{0:[nt,at],1:[dt],2:[dt]},[m("1010")]:{0:[lt,st],1:[pt],2:[pt]},[m("2121")]:{0:[dt],1:[dt],2:[nt,at]},[m("1212")]:{0:[pt],1:[pt],2:[lt,st]},[m("2120")]:{0:[zt],1:[zt],2:[ct,at]},[m("2021")]:{0:[Gt],1:[Gt],2:[nt,gt]},[m("1202")]:{0:[Ht],1:[Ht],2:[lt,ut]},[m("0212")]:{0:[Vt],1:[Vt],2:[st,ft]},[m("0102")]:{0:[ct,at],1:[zt],2:[zt]},[m("0201")]:{0:[nt,gt],1:[Gt],2:[Gt]},[m("1020")]:{0:[lt,ut],1:[Ht],2:[Ht]},[m("2010")]:{0:[st,ft],1:[Vt],2:[Vt]},[m("2020")]:{0:[ft,ut],1:[Io],2:[ct,gt]},[m("0202")]:{0:[gt,ct],1:[Io],2:[ft,ut]}};var Y={ISO_LINES:1,ISO_BANDS:2},dr={zIndex:0,zOffset:.005};function yt(n,t){return Array.isArray(t)?n<t[0]?0:n<t[1]?1:2:n>=t?1:0}function Wo(n){let{cellWeights:t,x:e,y:o,width:i,height:r}=n,s=n.threshold;n.thresholdValue&&(Uo.log.deprecated("thresholdValue","threshold")(),s=n.thresholdValue);let a=e<0,l=e>=i-1,c=o<0,g=o>=r-1,f=a||l||c||g,d={},p={};a||g?p.top=0:(d.top=t[(o+1)*i+e],p.top=yt(d.top,s)),l||g?p.topRight=0:(d.topRight=t[(o+1)*i+e+1],p.topRight=yt(d.topRight,s)),l||c?p.right=0:(d.right=t[o*i+e+1],p.right=yt(d.right,s)),a||c?p.current=0:(d.current=t[o*i+e],p.current=yt(d.current,s));let{top:x,topRight:h,right:A,current:S}=p,y=-1;Number.isFinite(s)&&(y=x<<3|h<<2|A<<1|S),Array.isArray(s)&&(y=x<<6|h<<4|A<<2|S);let _=0;return f||(_=yt((d.top+d.topRight+d.right+d.current)/4,s)),{code:y,meanCode:_}}function se(n){let{gridOrigin:t,cellSize:e,x:o,y:i,code:r,meanCode:s,type:a=Y.ISO_LINES}=n,l={...dr,...n.thresholdData},c=a===Y.ISO_BANDS?Bo[r]:Ro[r];Array.isArray(c)||(c=c[s]);let g=l.zIndex*l.zOffset,f=(o+1)*e[0],d=(i+1)*e[1],p=t[0]+f,x=t[1]+d;if(a===Y.ISO_BANDS){let A=[];return c.forEach(S=>{let y=[];S.forEach(_=>{let b=p+_[0]*e[0],O=x+_[1]*e[1];y.push([b,O,g])}),A.push(y)}),A}let h=[];return c.forEach(A=>{A.forEach(S=>{let y=p+S[0]*e[0],_=x+S[1]*e[1];h.push([y,_,g])})}),h}function zo({thresholdData:n,cellWeights:t,gridSize:e,gridOrigin:o,cellSize:i}){let r=[],s=[],a=e[0],l=e[1],c=0,g=0;for(let f of n){let{contour:d}=f,{threshold:p}=d;for(let x=-1;x<a;x++)for(let h=-1;h<l;h++){let{code:A,meanCode:S}=Wo({cellWeights:t,threshold:p,x,y:h,width:a,height:l}),y={type:Y.ISO_BANDS,gridOrigin:o,cellSize:i,x,y:h,width:a,height:l,code:A,meanCode:S,thresholdData:f};if(Array.isArray(p)){y.type=Y.ISO_BANDS;let _=se(y);for(let b of _)s[g++]={vertices:b,contour:d}}else{y.type=Y.ISO_LINES;let _=se(y);for(let b=0;b<_.length;b+=2)r[c++]={start:_[b],end:_[b+1],contour:d}}}}return{contourSegments:r,contourPolygons:s}}var Vo=M(E(),1);var Go=[255,255,255,255],pr=1,mr=1,hr={cellSize:{type:"number",min:1,max:1e3,value:1e3},getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:mr}],optional:!0,compare:3},zOffset:.005},Ho="positions",xr={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},kt=class extends w{initializeState(){super.initializeAggregationLayer({dimensions:xr}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:T.SUM}}}),this.getAttributeManager().add({[Ho]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(t){super.updateState(t);let e=!1,{oldProps:o,props:i}=t,{aggregationDirty:r}=this.state;(o.contours!==i.contours||o.zOffset!==i.zOffset)&&(e=!0,this._updateThresholdData(t.props)),this.getNumInstances()>0&&(r||e)&&this._generateContours()}renderLayers(){let{contourSegments:t,contourPolygons:e}=this.state.contourData,o=this.getSubLayerClass("lines",jt.LineLayer),i=this.getSubLayerClass("bands",jt.SolidPolygonLayer),r=t&&t.length>0&&new o(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:a=>a.start,getTargetPosition:a=>a.end,getColor:a=>a.contour.color||Go,getWidth:a=>a.contour.strokeWidth||pr}),s=e&&e.length>0&&new i(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||Go});return[r,s]}updateAggregationState(t){let{props:e,oldProps:o}=t,{cellSize:i,coordinateSystem:r}=e,{viewport:s}=this.context,a=o.cellSize!==i,l=e.gpuAggregation;this.state.gpuAggregation!==e.gpuAggregation&&l&&!C.isSupported(this.context.device)&&(Vo.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),l=!1);let c=l!==this.state.gpuAggregation;this.setState({gpuAggregation:l});let{dimensions:g}=this.state,f=this.isAttributeChanged(Ho),{data:d,weights:p}=g,{boundingBox:x}=this.state;if(f&&(x=wt(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:x})),f||a){let{gridOffset:S,translation:y,width:_,height:b,numCol:O,numRow:B}=It(x,i,s,r);this.allocateResources(B,O),this.setState({gridOffset:S,boundingBox:x,translation:y,posOffset:y.slice(),gridOrigin:[-1*y[0],-1*y[1]],width:_,height:b,numCol:O,numRow:B})}let h=f||c||this.isAggregationDirty(t,{dimension:d,compareAll:l}),A=this.isAggregationDirty(t,{dimension:p});A&&this._updateAccessors(t),(h||A)&&this._resetResults(),this.setState({aggregationDataDirty:h,aggregationWeightsDirty:A})}_updateAccessors(t){let{getWeight:e,aggregation:o,data:i}=t.props,{count:r}=this.state.weights;r&&(r.getWeight=e,r.operation=T[o]),this.setState({getValue:Q(o,e,{data:i})})}_resetResults(){let{count:t}=this.state.weights;t&&(t.aggregationData=null)}_generateContours(){let{numCol:t,numRow:e,gridOrigin:o,gridOffset:i,thresholdData:r}=this.state,{count:s}=this.state.weights,{aggregationData:a}=s;a||(a=s.aggregationBuffer.readSyncWebGL(),s.aggregationData=a);let{cellWeights:l}=C.getCellData({countsData:a}),c=zo({thresholdData:r,cellWeights:l,gridSize:[t,e],gridOrigin:o,cellSize:[i.xOffset,i.yOffset]});this.setState({contourData:c})}_updateThresholdData(t){let{contours:e,zOffset:o}=t,i=e.length,r=new Array(i);for(let s=0;s<i;s++){let a=e[s];r[s]={contour:a,zIndex:a.zIndex||s,zOffset:o}}this.setState({thresholdData:r})}},_t=kt;(()=>{kt.layerName="ContourLayer"})(),(()=>{kt.defaultProps=hr})();var Ko=M(E(),1);var $o=M(E(),1);var N=M(E(),1),Xo=M(q(),1);var qo=M(q(),1);var ko=`#version 300 es
|
|
299
|
+
`;var Li=[0,0,0,0],Fi=[0,255,0,255],wi=["minColor","maxColor","colorRange","colorDomain"],Ii={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:D},Dt=class extends et.Layer{getShaders(){return{vs:Ie,fs:Re,modules:[et.picking]}}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState(t){super.updateState(t);let{oldProps:e,props:o,changeFlags:i}=t,r=this.getAttributeManager();o.numInstances!==e.numInstances?r.invalidateAll():e.cellSizePixels!==o.cellSizePixels&&r.invalidate("instancePositions"),this._updateUniforms(e,o,i)}draw({uniforms:t}){let{parameters:e,maxTexture:o}=this.props,i=this.props.minColor||Li,r=this.props.maxColor||Fi,s=this.props.colorDomain||[1,0],a=this.state.model;a.setUniforms(t),a.setBindings({maxTexture:o}),a.setUniforms({minColor:i,maxColor:r,colorDomain:s}),a.setParameters({depthWriteEnabled:!1,...e}),a.draw(this.context.renderPass)}calculateInstancePositions(t,{numInstances:e}){let{width:o,height:i}=this.context.viewport,{cellSizePixels:r}=this.props,s=Math.ceil(o/r),{value:a,size:l}=t;for(let c=0;c<e;c++){let g=c%s,f=Math.floor(c/s);a[c*l+0]=g*r/o*2-1,a[c*l+1]=1-f*r/i*2,a[c*l+2]=0}}_getModel(){return new Ot.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot.Geometry({topology:"triangle-list",attributes:{positions:new Float32Array([0,0,0,1,0,0,1,1,0,0,0,0,1,1,0,0,1,0])}}),isInstanced:!0})}_shouldUseMinMax(){let{minColor:t,maxColor:e,colorDomain:o,colorRange:i}=this.props;return t||e?(et.log.deprecated("ScreenGridLayer props: minColor and maxColor","colorRange, colorDomain")(),!0):!(o||i)}_updateUniforms(t,e,o){let i=this.state.model;if(wi.some(r=>t[r]!==e[r])&&i.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),t.colorRange!==e.colorRange&&i.setUniforms({colorRange:z(e.colorRange)}),t.cellMarginPixels!==e.cellMarginPixels||t.cellSizePixels!==e.cellSizePixels||o.viewportChanged){let{width:r,height:s}=this.context.viewport,{cellSizePixels:a,cellMarginPixels:l}=this.props,c=a>l?l:0,g=new Float32Array([(a-c)/r*2,-(a-c)/s*2,1]);i.setUniforms({cellScale:g})}}},tt=Dt;(()=>{Dt.layerName="ScreenGridCellLayer"})(),(()=>{Dt.defaultProps=Ii})();var to=M(E(),1);var ot=M(E(),1);function Be(n,t){let e={};for(let o in n)t.includes(o)||(e[o]=n[o]);return e}var oe=class extends ot.CompositeLayer{initializeAggregationLayer(t){super.initializeState(this.context),this.setState({ignoreProps:Be(this.constructor._propTypes,t.data.props),dimensions:t})}updateState(t){super.updateState(t);let{changeFlags:e}=t;if(e.extensionsChanged){let o=this.getShaders({});o&&o.defines&&(o.defines.NON_INSTANCED_MODEL=1),this.updateShaders(o)}this._updateAttributes()}updateAttributes(t){this.setState({changedAttributes:t})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:t,mousePosition:e,device:o}=this.context;return Object.assign(Object.create(this.props),{viewport:t,mousePosition:e,picking:{isActive:0},devicePixelRatio:o.canvasContext.cssToDeviceRatio()})}updateShaders(t){}isAggregationDirty(t,e={}){let{props:o,oldProps:i,changeFlags:r}=t,{compareAll:s=!1,dimension:a}=e,{ignoreProps:l}=this.state,{props:c,accessors:g=[]}=a,{updateTriggersChanged:f}=r;if(r.dataChanged)return!0;if(f){if(f.all)return!0;for(let d of g)if(f[d])return!0}if(s)return r.extensionsChanged?!0:(0,ot._compareProps)({oldProps:i,newProps:o,ignoreProps:l,propTypes:this.constructor._propTypes});for(let d of c)if(o[d]!==i[d])return!0;return!1}isAttributeChanged(t){let{changedAttributes:e}=this.state;return t?e&&e[t]!==void 0:!Ri(e)}_getAttributeManager(){return new ot.AttributeManager(this.context.device,{id:this.props.id,stats:this.context.stats})}},P=oe;(()=>{oe.layerName="AggregationLayer"})();function Ri(n){let t=!0;for(let e in n){t=!1;break}return t}var We=M(E(),1);function Lt(n,t,e){let o=e;return o.domain=()=>n,o.range=()=>t,o}function Ue(n,t){return Lt(n,t,o=>ki(n,t,o))}function Bi(n,t){return Lt(n,t,o=>ji(n,t,o))}function Ui(n,t){let e=n.sort(ze),o=0,i=Math.max(1,t.length),r=new Array(i-1);for(;++o<i;)r[o-1]=Wi(e,o/i);let s=a=>Gi(r,t,a);return s.thresholds=()=>r,Lt(n,t,s)}function ze(n,t){return n-t}function Wi(n,t){let e=n.length;if(t<=0||e<2)return n[0];if(t>=1)return n[e-1];let o=(e-1)*t,i=Math.floor(o),r=n[i],s=n[i+1];return r+(s-r)*(o-i)}function zi(n,t){let e=0,o=n.length;for(;e<o;){let i=e+o>>>1;ze(n[i],t)>0?o=i:e=i+1}return e}function Gi(n,t,e){return t[zi(n,e)]}function Hi(n,t,e,o){let i=`${o}`,r=t.get(i);return r===void 0&&(r=n.push(o),t.set(i,r)),e[(r-1)%e.length]}function Vi(n,t){let e=new Map,o=[];for(let r of n){let s=`${r}`;e.has(s)||e.set(s,o.push(r))}return Lt(n,t,r=>Hi(o,e,t,r))}function ki(n,t,e){let o=n[1]-n[0];if(o<=0)return We.log.warn("quantizeScale: invalid domain, returning range[0]")(),t[0];let i=o/t.length,r=Math.floor((e-n[0])/i),s=Math.max(Math.min(r,t.length-1),0);return t[s]}function ji(n,t,e){return(e-n[0])/(n[1]-n[0])*(t[1]-t[0])+t[0]}function Ge(n){return n!=null}function Xi(n){let t=[];return n.forEach(e=>{!t.includes(e)&&Ge(e)&&t.push(e)}),t}function He(n,t){return(typeof t=="function"?n.map(t):n).filter(Ge)}function Ve(n,t){return He(n,t)}function ke(n,t){return Xi(He(n,t))}function je(n,t,e){return Math.max(t,Math.min(e,n))}function Xe(n){switch(n){case"quantize":return Ue;case"linear":return Bi;case"quantile":return Ui;case"ordinal":return Vi;default:return Ue}}var Ye=n=>n.length,qi=3402823466e29,$e=n=>n.points,Ke=n=>n.index,qe=(n,t)=>n<t?-1:n>t?1:n>=t?0:NaN,Yi={getValue:Ye,getPoints:$e,getIndex:Ke,filterData:null},F=class{constructor(t=[],e=Yi){this.aggregatedBins=this.getAggregatedBins(t,e),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(t,e){let{getValue:o=Ye,getPoints:i=$e,getIndex:r=Ke,filterData:s}=e,a=typeof s=="function",l=t.length,c=[],g=0;for(let f=0;f<l;f++){let d=t[f],p=i(d),x=r(d),h=a?p.filter(s):p;d.filteredPoints=a?h:null;let A=h.length?o(h):null;A!=null&&(c[g]={i:Number.isFinite(x)?x:f,value:A,counts:h.length},g++)}return c}_percentileToIndex(t){let e=this.sortedBins.length;if(e<2)return[0,0];let[o,i]=t.map(a=>je(a,0,100)),r=Math.ceil(o/100*(e-1)),s=Math.floor(i/100*(e-1));return[r,s]}getBinMap(){let t={};for(let e of this.aggregatedBins)t[e.i]=e;return t}_updateMinMaxValues(){let t=0,e=0,o=qi,i=0;for(let r of this.aggregatedBins)t=t>r.counts?t:r.counts,e=e>r.value?e:r.value,o=o<r.value?o:r.value,i+=r.counts;this.maxCount=t,this.maxValue=e,this.minValue=o,this.totalCount=i}getValueRange(t){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((i,r)=>qe(i.value,r.value))),!this.sortedBins.length)return[];let e=0,o=this.sortedBins.length-1;if(Array.isArray(t)){let i=this._percentileToIndex(t);e=i[0],o=i[1]}return[this.sortedBins[e].value,this.sortedBins[o].value]}getValueDomainByScale(t,[e=0,o=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((r,s)=>qe(r.value,s.value))),!this.sortedBins.length)return[];let i=this._percentileToIndex([e,o]);return this._getScaleDomain(t,i)}_getScaleDomain(t,[e,o]){let i=this.sortedBins;switch(t){case"quantize":case"linear":return[i[e].value,i[o].value];case"quantile":return Ve(i.slice(e,o+1),r=>r.value);case"ordinal":return ke(i,r=>r.value);default:return[i[e].value,i[o].value]}}};var Je=M(E(),1);var G=M(E(),1),Ze=6378e3;function Ft(n){return Number.isFinite(n)?n:0}function wt(n,t){let e=n.positions.value,o=1/0,i=-1/0,r=1/0,s=-1/0,a,l;for(let g=0;g<t;g++)l=e[g*3],a=e[g*3+1],o=a<o?a:o,i=a>i?a:i,r=l<r?l:r,s=l>s?l:s;return{xMin:Ft(r),xMax:Ft(s),yMin:Ft(o),yMax:Ft(i)}}function $i(n,t,e,o){let{width:i,height:r}=o,s=e===G.COORDINATE_SYSTEM.CARTESIAN?[-i/2,-r/2]:[-180,-90];G.log.assert(e===G.COORDINATE_SYSTEM.CARTESIAN||e===G.COORDINATE_SYSTEM.LNGLAT||e===G.COORDINATE_SYSTEM.DEFAULT);let{xMin:a,yMin:l}=n;return[-1*(Qe(a-s[0],t.xOffset)+s[0]),-1*(Qe(l-s[1],t.yOffset)+s[1])]}function Qe(n,t){let e=n<0?-1:1,o=e<0?Math.abs(n)+t:Math.abs(n);return o=Math.floor(o/t)*t,o*e}function ie(n,t,e=!0){if(!e)return{xOffset:t,yOffset:t};let{yMin:o,yMax:i}=n,r=(o+i)/2;return Ki(t,r)}function It(n,t,e,o){let i=ie(n,t,o!==G.COORDINATE_SYSTEM.CARTESIAN),r=$i(n,i,o,e),{xMin:s,yMin:a,xMax:l,yMax:c}=n,g=l-s+i.xOffset,f=c-a+i.yOffset,d=Math.ceil(g/i.xOffset),p=Math.ceil(f/i.yOffset);return{gridOffset:i,translation:r,width:g,height:f,numCol:d,numRow:p}}function Ki(n,t){let e=Qi(n),o=Zi(t,n);return{yOffset:e,xOffset:o}}function Qi(n){return n/Ze*(180/Math.PI)}function Zi(n,t){return t/Ze*(180/Math.PI)/Math.cos(n*Math.PI/180)}function it(n,t){let e=Ji(n,t),o=tr(e);return{gridHash:e.gridHash,gridOffset:e.gridOffset,data:o}}function Ji(n,t){let{data:e=[],cellSize:o}=n,{attributes:i,viewport:r,projectPoints:s,numInstances:a}=t,l=i.positions.value,{size:c}=i.positions.getAccessor(),g=t.boundingBox||er(i.positions,a),f=t.posOffset||[180,90],d=t.gridOffset||ie(g,o);if(d.xOffset<=0||d.yOffset<=0)return{gridHash:{},gridOffset:d,offsets:[0,0]};let{width:p,height:x}=r,h=Math.ceil(p/d.xOffset),A=Math.ceil(x/d.yOffset),S={},{iterable:y,objectInfo:_}=(0,Je.createIterable)(e),b=new Array(3);for(let O of y){_.index++,b[0]=l[_.index*c],b[1]=l[_.index*c+1],b[2]=c>=3?l[_.index*c+2]:0;let[B,mt]=s?r.project(b):b;if(Number.isFinite(B)&&Number.isFinite(mt)){let k=Math.floor((mt+f[1])/d.yOffset),j=Math.floor((B+f[0])/d.xOffset);if(!s||j>=0&&j<h&&k>=0&&k<A){let X=`${k}-${j}`;S[X]=S[X]||{count:0,points:[],lonIdx:j,latIdx:k},S[X].count+=1,S[X].points.push({source:O,index:_.index})}}}return{gridHash:S,gridOffset:d,offsets:[f[0]*-1,f[1]*-1]}}function tr({gridHash:n,gridOffset:t,offsets:e}){let o=new Array(Object.keys(n).length),i=0;for(let r in n){let s=r.split("-"),a=parseInt(s[0],10),l=parseInt(s[1],10),c=i++;o[c]={index:c,position:[e[0]+t.xOffset*l,e[1]+t.yOffset*a],...n[r]}}return o}function er(n,t){let e=n.value,{size:o}=n.getAccessor(),i=1/0,r=-1/0,s=1/0,a=-1/0,l,c;for(let g=0;g<t;g++)c=e[g*o],l=e[g*o+1],Number.isFinite(c)&&Number.isFinite(l)&&(i=l<i?l:i,r=l>r?l:r,s=c<s?c:s,a=c>a?c:a);return{xMin:s,xMax:a,yMin:i,yMax:r}}var re=class extends P{initializeAggregationLayer({dimensions:t}){super.initializeAggregationLayer(t),this.setState({layerData:{},gpuGridAggregator:new C(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:it})}updateState(t){super.updateState(t),this.updateAggregationState(t);let{aggregationDataDirty:e,aggregationWeightsDirty:o,gpuAggregation:i}=this.state;if(this.getNumInstances()<=0)return;let r=!1;(e||i&&o)&&(this._updateAggregation(t),r=!0),!i&&(e||o)&&(this._updateWeightBins(),this._uploadAggregationResults(),r=!0),this.setState({aggregationDirty:r})}finalizeState(t){let{count:e}=this.state.weights;e&&e.aggregationBuffer&&e.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(t)}updateShaders(t){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(t)}updateAggregationState(t){to.log.assert(!1)}allocateResources(t,e){if(this.state.numRow!==t||this.state.numCol!==e){let o=e*t*4*4,{weights:i}=this.state;for(let r in i){let s=i[r];s.aggregationBuffer&&s.aggregationBuffer.delete(),s.aggregationBuffer=this.context.device.createBuffer({byteLength:o,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:t,maxMinData:e,maxData:o,minData:i}){let{count:r}=this.state.weights;r&&(r.aggregationData=t,r.maxMinData=e,r.maxData=o,r.minData=i)}_updateAggregation(t){let{cpuGridAggregator:e,gpuGridAggregator:o,gridOffset:i,posOffset:r,translation:s=[0,0],scaling:a=[0,0,0],boundingBox:l,projectPoints:c,gpuAggregation:g,numCol:f,numRow:d}=this.state,{props:p}=t,{viewport:x}=this.context,h=this.getAttributes(),A=this.getNumInstances();if(g){let{weights:S}=this.state;o.run({weights:S,cellSize:[i.xOffset,i.yOffset],numCol:f,numRow:d,translation:s,scaling:a,vertexCount:A,projectPoints:c,attributes:h,moduleSettings:this.getModuleSettings()})}else{let S=e(p,{gridOffset:i,projectPoints:c,attributes:h,viewport:x,posOffset:r,boundingBox:l});this.setState({layerData:S})}}_updateWeightBins(){let{getValue:t}=this.state,e=new F(this.state.layerData.data||[],{getValue:t});this.setState({sortedBins:e})}_uploadAggregationResults(){let{numCol:t,numRow:e}=this.state,{data:o}=this.state.layerData,{aggregatedBins:i,minValue:r,maxValue:s,totalCount:a}=this.state.sortedBins,l=4,c=t*e*l,g=new Float32Array(c).fill(0);for(let x of i){let{lonIdx:h,latIdx:A}=o[x.i],{value:S,counts:y}=x,_=(h+A*t)*l;g[_]=S,g[_+l-1]=y}let f=new Float32Array([s,0,0,r]),d=new Float32Array([s,0,0,a]),p=new Float32Array([r,0,0,a]);this.updateResults({aggregationData:g,maxMinData:f,maxData:d,minData:p})}},w=re;(()=>{re.layerName="GridAggregationLayer"})();var or={...tt.defaultProps,getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},eo="positions",ir={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Rt=class extends w{initializeState(){super.initializeAggregationLayer({dimensions:ir,getCellSize:o=>o.cellSizePixels});let t={count:{size:1,operation:T.SUM,needMax:!0,maxTexture:Z(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:t,subLayerData:{attributes:{}},maxTexture:t.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[eo]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:t}){return this.state.supported&&t.somethingChanged}updateState(t){super.updateState(t)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:t,numRow:e,numCol:o,weights:i}=this.state,{updateTriggers:r}=this.props,{aggregationBuffer:s}=i.count,a=this.getSubLayerClass("cells",tt);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:r}),{data:{attributes:{instanceCounts:s}},maxTexture:t,numInstances:e*o})}finalizeState(t){super.finalizeState(t);let{aggregationBuffer:e,maxBuffer:o,maxTexture:i}=this.state;e?.delete(),o?.delete(),i?.delete()}getPickingInfo({info:t}){let{index:e}=t;if(e>=0){let{gpuGridAggregator:o,gpuAggregation:i,weights:r}=this.state,s=i?o.getData("count"):r.count;t.object=C.getAggregationData({pixelIndex:e,...s})}return t}updateResults({aggregationData:t,maxData:e}){let{count:o}=this.state.weights;o.aggregationData=t,o.aggregationBuffer.write(t),o.maxData=e,o.maxTexture.setImageData({data:e})}updateAggregationState(t){let e=t.props.cellSizePixels,o=t.oldProps.cellSizePixels!==e,{viewportChanged:i}=t.changeFlags,r=t.props.gpuAggregation;this.state.gpuAggregation!==t.props.gpuAggregation&&r&&!C.isSupported(this.context.device)&&(oo.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),r=!1);let s=r!==this.state.gpuAggregation;this.setState({gpuAggregation:r});let a=this.isAttributeChanged(eo),{dimensions:l}=this.state,{data:c,weights:g}=l,f=a||s||i||this.isAggregationDirty(t,{compareAll:r,dimension:c}),d=this.isAggregationDirty(t,{dimension:g});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:d});let{viewport:p}=this.context;if(i||o){let{width:x,height:h}=p,A=Math.ceil(x/e),S=Math.ceil(h/e);this.allocateResources(S,A),this.setState({scaling:[x/2,-h/2,1],gridOffset:{xOffset:e,yOffset:e},width:x,height:h,numCol:A,numRow:S})}d&&this._updateAccessors(t),(f||d)&&this._resetResults()}_updateAccessors(t){let{getWeight:e,aggregation:o,data:i}=t.props,{count:r}=this.state.weights;r&&(r.getWeight=e,r.operation=T[o]),this.setState({getValue:Q(o,e,{data:i})})}_resetResults(){let{count:t}=this.state.weights;t&&(t.aggregationData=null)}},St=Rt;(()=>{Rt.layerName="ScreenGridLayer"})(),(()=>{Rt.defaultProps=or})();var ao=M($(),1);function io(){}var ro=["getBins","getDomain","getScaleFunc"],no=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],rr=n=>n.cellSize,I=class{constructor(t){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=t.getCellSize||rr,this._getAggregator=t.getAggregator,this._addDimension(t.dimensions||no)}static defaultDimensions(){return no}updateState(t,e){let{oldProps:o,props:i,changeFlags:r}=t;this.updateGetValueFuncs(o,i,r);let s=this.needsReProjectPoints(o,i,r),a=!1;return r.dataChanged||s?(this.getAggregatedData(i,e),a=!0):((this.getDimensionChanges(o,i,r)||[]).forEach(c=>typeof c=="function"&&c()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(t){this.state={...this.state,...t}}setDimensionState(t,e){this.setState({dimensions:{...this.state.dimensions,[t]:{...this.state.dimensions[t],...e}}})}normalizeResult(t={}){return t.hexagons?{data:t.hexagons,...t}:t.layerData?{data:t.layerData,...t}:t}getAggregatedData(t,e){let i=this._getAggregator(t)(t,e);this.setState({layerData:this.normalizeResult(i)}),this.changeFlags={layerData:!0},this.getSortedBins(t)}updateGetValueFuncs(t,e,o){for(let i in this.dimensionUpdaters){let{value:r,weight:s,aggregation:a}=this.dimensionUpdaters[i].getBins.triggers,l=e[r.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[i].getBins,t,e,o)&&(l?l=Me(l,{data:e.data}):l=Q(e[a.prop],e[s.prop],{data:e.data})),l&&this.setDimensionState(i,{getValue:l})}}needsReProjectPoints(t,e,o){return this._getCellSize(t)!==this._getCellSize(e)||this._getAggregator(t)!==this._getAggregator(e)||o.updateTriggersChanged&&(o.updateTriggersChanged.all||o.updateTriggersChanged.getPosition)}addDimension(t){this._addDimension(t)}_addDimension(t=[]){t.forEach(e=>{let{key:o}=e;this.dimensionUpdaters[o]=this.getDimensionUpdaters(e),this.state.dimensions[o]={getValue:null,domain:null,sortedBins:null,scaleFunc:io}})}getDimensionUpdaters({key:t,accessor:e,pickingInfo:o,getBins:i,getDomain:r,getScaleFunc:s,nullValue:a}){return{key:t,accessor:e,pickingInfo:o,getBins:{updater:this.getDimensionSortedBins.bind(this),...i},getDomain:{updater:this.getDimensionValueDomain.bind(this),...r},getScaleFunc:{updater:this.getDimensionScale.bind(this),...s},attributeAccessor:this.getSubLayerDimensionAttribute(t,a)}}needUpdateDimensionStep(t,e,o,i){return Object.values(t.triggers).some(r=>r.updateTrigger?i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged[r.updateTrigger]):e[r.prop]!==o[r.prop])}getDimensionChanges(t,e,o){let i=[];for(let r in this.dimensionUpdaters){let s=ro.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[r][a],t,e,o));s&&i.push(this.dimensionUpdaters[r][s].updater.bind(this,e,this.dimensionUpdaters[r]))}return i.length?i:null}getUpdateTriggers(t){let e=t.updateTriggers||{},o={};for(let i in this.dimensionUpdaters){let{accessor:r}=this.dimensionUpdaters[i];o[r]={},ro.forEach(s=>{Object.values(this.dimensionUpdaters[i][s].triggers).forEach(({prop:a,updateTrigger:l})=>{if(l){let c=e[l];typeof c=="object"&&!Array.isArray(c)?Object.assign(o[r],c):c!==void 0&&(o[r][a]=c)}else o[r][a]=t[a]})})}return o}getSortedBins(t){for(let e in this.dimensionUpdaters)this.getDimensionSortedBins(t,this.dimensionUpdaters[e])}getDimensionSortedBins(t,e){let{key:o}=e,{getValue:i}=this.state.dimensions[o],r=new F(this.state.layerData.data||[],{getValue:i,filterData:t._filterData});this.setDimensionState(o,{sortedBins:r}),this.getDimensionValueDomain(t,e)}getDimensionValueDomain(t,e){let{getDomain:o,key:i}=e,{triggers:{lowerPercentile:r,upperPercentile:s,scaleType:a}}=o,l=this.state.dimensions[i].sortedBins.getValueDomainByScale(t[a.prop],[t[r.prop],t[s.prop]]);this.setDimensionState(i,{valueDomain:l}),this.getDimensionScale(t,e)}getDimensionScale(t,e){let{key:o,getScaleFunc:i,getDomain:r}=e,{domain:s,range:a}=i.triggers,{scaleType:l}=r.triggers,{onSet:c}=i,g=t[a.prop],f=t[s.prop]||this.state.dimensions[o].valueDomain,p=Xe(l&&t[l.prop])(f,g);typeof c=="object"&&typeof t[c.props]=="function"&&t[c.props](p.domain()),this.setDimensionState(o,{scaleFunc:p})}getSubLayerDimensionAttribute(t,e){return o=>{let{sortedBins:i,scaleFunc:r}=this.state.dimensions[t],s=i.binMap[o.index];if(s&&s.counts===0)return e;let a=s&&s.value,l=r.domain();return a>=l[0]&&a<=l[l.length-1]?r(a):e}}getSubLayerAccessors(t){let e={};for(let o in this.dimensionUpdaters){let{accessor:i}=this.dimensionUpdaters[o];e[i]=this.getSubLayerDimensionAttribute(t,o)}return e}getPickingInfo({info:t}){let e=t.picked&&t.index>-1,o=null;if(e){let i=this.state.layerData.data[t.index],r={};for(let s in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[s],{sortedBins:l}=this.state.dimensions[s],c=l.binMap[i.index]&&l.binMap[i.index].value;r[a]=c}o=Object.assign(r,i,{points:i.filteredPoints||i.points})}return t.picked=Boolean(o),t.object=o,t}getAccessor(t){return this.dimensionUpdaters.hasOwnProperty(t)?this.dimensionUpdaters[t].attributeAccessor:io}};function so(){}var nr={colorDomain:null,colorRange:D,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:so,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:so,gridAggregator:it,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:n=>n.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},Bt=class extends P{initializeState(){let t=new I({getAggregator:o=>o.gridAggregator,getCellSize:o=>o.cellSize});this.state={cpuAggregator:t,aggregatorState:t.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(t){super.updateState(t),this.setState({aggregatorState:this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:t,extruded:e,cellSize:o,coverage:i,material:r,transitions:s}=this.props,{cpuAggregator:a}=this.state,l=this.getSubLayerClass("grid-cell",ao.GridCellLayer),c=this._getSublayerUpdateTriggers();return new l({cellSize:o,coverage:i,material:r,elevationScale:t,extruded:e,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:s&&{getFillColor:s.getColorValue||s.getColorWeight,getElevation:s.getElevationValue||s.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:c}),{data:a.state.layerData.data})}},H=Bt;(()=>{Bt.layerName="CPUGridLayer"})(),(()=>{Bt.defaultProps=nr})();var uo=M(E(),1),go=M($(),1);var rt=Math.PI/3,sr=[0,rt,2*rt,3*rt,4*rt,5*rt];function ar(n){return n[0]}function lr(n){return n[1]}function ne(){var n=0,t=0,e=1,o=1,i=ar,r=lr,s,a,l;function c(f){var d={},p=[],x,h=f.length;for(x=0;x<h;++x)if(!(isNaN(S=+i.call(null,A=f[x],x,f))||isNaN(y=+r.call(null,A,x,f)))){var A,S,y,_=Math.round(y=y/l),b=Math.round(S=S/a-(_&1)/2),O=y-_;if(Math.abs(O)*3>1){var B=S-b,mt=b+(S<b?-1:1)/2,k=_+(y<_?-1:1),j=S-mt,X=y-k;B*B+O*O>j*j+X*X&&(b=mt+(_&1?1:-1)/2,_=k)}var me=b+"-"+_,ht=d[me];ht?ht.push(A):(p.push(ht=d[me]=[A]),ht.x=(b+(_&1)/2)*a,ht.y=_*l)}return p}function g(f){var d=0,p=0;return sr.map(function(x){var h=Math.sin(x)*f,A=-Math.cos(x)*f,S=h-d,y=A-p;return d=h,p=A,[S,y]})}return c.hexagon=function(f){return"m"+g(f==null?s:+f).join("l")+"z"},c.centers=function(){for(var f=[],d=Math.round(t/l),p=Math.round(n/a),x=d*l;x<o+s;x+=l,++d)for(var h=p*a+(d&1)*a/2;h<e+a/2;h+=a)f.push([h,x]);return f},c.mesh=function(){var f=g(s).slice(0,4).join("l");return c.centers().map(function(d){return"M"+d+"m"+f}).join("")},c.x=function(f){return arguments.length?(i=f,c):i},c.y=function(f){return arguments.length?(r=f,c):r},c.radius=function(f){return arguments.length?(s=+f,a=s*2*Math.sin(rt),l=s*1.5,c):s},c.size=function(f){return arguments.length?(n=t=0,e=+f[0],o=+f[1],c):[e-n,o-t]},c.extent=function(f){return arguments.length?(n=+f[0][0],t=+f[0][1],e=+f[1][0],o=+f[1][1],c):[[n,t],[e,o]]},c.radius(1)}var Ut=M(E(),1);function lo(n,t){let{data:e,radius:o}=n,{viewport:i,attributes:r}=t,s=e.length?cr(e,t):null,a=ur(o,i,s),l=[],{iterable:c,objectInfo:g}=(0,Ut.createIterable)(e),f=r.positions.value,{size:d}=r.positions.getAccessor();for(let h of c){g.index++;let A=g.index*d,S=[f[A],f[A+1]];Number.isFinite(S[0])&&Number.isFinite(S[1])?l.push({screenCoord:i.projectFlat(S),source:h,index:g.index}):Ut.log.warn("HexagonLayer: invalid position")()}return{hexagons:ne().radius(a).x(h=>h.screenCoord[0]).y(h=>h.screenCoord[1])(l).map((h,A)=>({position:i.unprojectFlat([h.x,h.y]),points:h,index:A})),radiusCommon:a}}function cr(n,t){let{attributes:e}=t,o=e.positions.value,{size:i}=e.positions.getAccessor(),r=1/0,s=1/0,a=-1/0,l=-1/0,c;for(c=0;c<i*n.length;c+=i){let g=o[c],f=o[c+1];Number.isFinite(g)&&Number.isFinite(f)&&(r=Math.min(g,r),a=Math.max(g,a),s=Math.min(f,s),l=Math.max(f,l))}return[r,s,a,l].every(Number.isFinite)?[(r+a)/2,(s+l)/2]:null}function ur(n,t,e){let{unitsPerMeter:o}=t.getDistanceScales(e);return n*o[0]}function co(){}var gr={colorDomain:null,colorRange:D,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",value:0,min:0,max:100},upperPercentile:{type:"number",value:100,min:0,max:100},colorScaleType:"quantize",onSetColorDomain:co,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",value:0,min:0,max:100},elevationUpperPercentile:{type:"number",value:100,min:0,max:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:co,radius:{type:"number",value:1e3,min:1},coverage:{type:"number",min:0,max:1,value:1},extruded:!1,hexagonAggregator:lo,getPosition:{type:"accessor",value:n=>n.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},Wt=class extends P{initializeState(){let t=new I({getAggregator:o=>o.hexagonAggregator,getCellSize:o=>o.radius});this.state={cpuAggregator:t,aggregatorState:t.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(t){if(super.updateState(t),t.changeFlags.propsOrDataChanged){let e=this.state.cpuAggregator.updateState(t,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==e.layerData){let{hexagonVertices:o}=e.layerData||{};this.setState({vertices:o&&this.convertLatLngToMeterOffset(o)})}this.setState({aggregatorState:e})}}convertLatLngToMeterOffset(t){let{viewport:e}=this.context;if(Array.isArray(t)&&t.length===6){let o=t[0],i=t[3],r=[(o[0]+i[0])/2,(o[1]+i[1])/2],s=e.projectFlat(r),{metersPerUnit:a}=e.getDistanceScales(r);return t.map(c=>{let g=e.projectFlat(c);return[(g[0]-s[0])*a[0],(g[1]-s[1])*a[1]]})}return uo.log.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:t}){return this.state.cpuAggregator.getPickingInfo({info:t})}_onGetSublayerColor(t){return this.state.cpuAggregator.getAccessor("fillColor")(t)}_onGetSublayerElevation(t){return this.state.cpuAggregator.getAccessor("elevation")(t)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:t,extruded:e,coverage:o,material:i,transitions:r}=this.props,{aggregatorState:s,vertices:a}=this.state,l=this.getSubLayerClass("hexagon-cell",go.ColumnLayer),c=this._getSublayerUpdateTriggers(),g=a?{vertices:a,radius:1}:{radius:s.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new l({...g,diskResolution:6,elevationScale:t,extruded:e,coverage:o,material:i,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:r&&{getFillColor:r.getColorValue||r.getColorWeight,getElevation:r.getElevationValue||r.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:c}),{data:s.layerData.data})}},At=Wt;(()=>{Wt.layerName="HexagonLayer"})(),(()=>{Wt.defaultProps=gr})();var jt=M($(),1);var Uo=M(E(),1);var v=.16666666666666666,u={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},nt=[u.W,u.SW,u.S],st=[u.S,u.SE,u.E],at=[u.E,u.NE,u.N],lt=[u.NW,u.W,u.N],ct=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5]],ut=[[-v,-.5],[v,-.5],[.5,-v],[.5,v]],gt=[[.5,-v],[.5,v],[v,.5],[-v,.5]],ft=[[-.5,v],[-.5,-v],[v,.5],[-v,.5]],fo=[u.W,u.SW,u.SE,u.E],po=[u.S,u.SE,u.NE,u.N],mo=[u.NW,u.W,u.E,u.NE],ho=[u.NW,u.SW,u.S,u.N],xo=[[-.5,v],[-.5,-v],[.5,-v],[.5,v]],vo=[[-v,-.5],[v,-.5],[v,.5],[-v,.5]],fr=[u.NW,u.SW,u.SE,u.NE],So=[u.NW,u.SW,u.SE,u.E,u.N],Ao=[u.W,u.SW,u.SE,u.NE,u.N],yo=[u.NW,u.W,u.S,u.SE,u.NE],_o=[u.NW,u.SW,u.S,u.E,u.NE],bo=[u.NW,u.W,[.5,-v],[.5,v],u.N],Mo=[[-v,-.5],[v,-.5],u.E,u.NE,u.N],To=[[-.5,v],[-.5,-v],u.S,u.SE,u.E],Co=[u.W,u.SW,u.S,[v,.5],[-v,.5]],Eo=[u.NW,u.W,[-v,-.5],[v,-.5],u.N],Po=[[-.5,v],[-.5,-v],u.E,u.NE,u.N],No=[u.S,u.SE,u.E,[v,.5],[-v,.5]],Do=[u.W,u.SW,u.S,[.5,-v],[.5,v]],Oo=[u.W,u.SW,u.SE,u.E,[v,.5],[-v,.5]],Lo=[[-.5,v],[-.5,-v],u.S,u.SE,u.NE,u.N],Fo=[u.NW,u.W,[-v,-.5],[v,-.5],u.E,u.NE],wo=[u.NW,u.SW,u.S,[.5,-v],[.5,v],u.N],dt=[u.W,u.SW,u.S,u.E,u.NE,u.N],pt=[u.NW,u.W,u.S,u.SE,u.E,u.N],zt=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5],u.E,u.NE,u.N],Gt=[u.W,u.SW,u.S,[.5,-v],[.5,v],[v,.5],[-v,.5]],Ht=[u.NW,u.W,[-v,-.5],[v,-.5],[.5,-v],[.5,v],u.N],Vt=[[-.5,v],[-.5,-v],u.S,u.SE,u.E,[v,.5],[-v,.5]],Io=[[-.5,v],[-.5,-v],[-v,-.5],[v,-.5],[.5,-v],[.5,v],[v,.5],[-v,.5]],Ro={0:[],1:[[u.W,u.S]],2:[[u.S,u.E]],3:[[u.W,u.E]],4:[[u.N,u.E]],5:{0:[[u.W,u.S],[u.N,u.E]],1:[[u.W,u.N],[u.S,u.E]]},6:[[u.N,u.S]],7:[[u.W,u.N]],8:[[u.W,u.N]],9:[[u.N,u.S]],10:{0:[[u.W,u.N],[u.S,u.E]],1:[[u.W,u.S],[u.N,u.E]]},11:[[u.N,u.E]],12:[[u.W,u.E]],13:[[u.S,u.E]],14:[[u.W,u.S]],15:[]};function m(n){return parseInt(n,4)}var Bo={[m("0000")]:[],[m("2222")]:[],[m("2221")]:[nt],[m("2212")]:[st],[m("2122")]:[at],[m("1222")]:[lt],[m("0001")]:[nt],[m("0010")]:[st],[m("0100")]:[at],[m("1000")]:[lt],[m("2220")]:[ct],[m("2202")]:[ut],[m("2022")]:[gt],[m("0222")]:[ft],[m("0002")]:[ct],[m("0020")]:[ut],[m("0200")]:[gt],[m("2000")]:[ft],[m("0011")]:[fo],[m("0110")]:[po],[m("1100")]:[mo],[m("1001")]:[ho],[m("2211")]:[fo],[m("2112")]:[po],[m("1122")]:[mo],[m("1221")]:[ho],[m("2200")]:[xo],[m("2002")]:[vo],[m("0022")]:[xo],[m("0220")]:[vo],[m("1111")]:[fr],[m("1211")]:[So],[m("2111")]:[Ao],[m("1112")]:[yo],[m("1121")]:[_o],[m("1011")]:[So],[m("0111")]:[Ao],[m("1110")]:[yo],[m("1101")]:[_o],[m("1200")]:[bo],[m("0120")]:[Mo],[m("0012")]:[To],[m("2001")]:[Co],[m("1022")]:[bo],[m("2102")]:[Mo],[m("2210")]:[To],[m("0221")]:[Co],[m("1002")]:[Eo],[m("2100")]:[Po],[m("0210")]:[No],[m("0021")]:[Do],[m("1220")]:[Eo],[m("0122")]:[Po],[m("2012")]:[No],[m("2201")]:[Do],[m("0211")]:[Oo],[m("2110")]:[Lo],[m("1102")]:[Fo],[m("1021")]:[wo],[m("2011")]:[Oo],[m("0112")]:[Lo],[m("1120")]:[Fo],[m("1201")]:[wo],[m("2101")]:[dt],[m("0121")]:[dt],[m("1012")]:[pt],[m("1210")]:[pt],[m("0101")]:{0:[nt,at],1:[dt],2:[dt]},[m("1010")]:{0:[lt,st],1:[pt],2:[pt]},[m("2121")]:{0:[dt],1:[dt],2:[nt,at]},[m("1212")]:{0:[pt],1:[pt],2:[lt,st]},[m("2120")]:{0:[zt],1:[zt],2:[ct,at]},[m("2021")]:{0:[Gt],1:[Gt],2:[nt,gt]},[m("1202")]:{0:[Ht],1:[Ht],2:[lt,ut]},[m("0212")]:{0:[Vt],1:[Vt],2:[st,ft]},[m("0102")]:{0:[ct,at],1:[zt],2:[zt]},[m("0201")]:{0:[nt,gt],1:[Gt],2:[Gt]},[m("1020")]:{0:[lt,ut],1:[Ht],2:[Ht]},[m("2010")]:{0:[st,ft],1:[Vt],2:[Vt]},[m("2020")]:{0:[ft,ut],1:[Io],2:[ct,gt]},[m("0202")]:{0:[gt,ct],1:[Io],2:[ft,ut]}};var Y={ISO_LINES:1,ISO_BANDS:2},dr={zIndex:0,zOffset:.005};function yt(n,t){return Array.isArray(t)?n<t[0]?0:n<t[1]?1:2:n>=t?1:0}function Wo(n){let{cellWeights:t,x:e,y:o,width:i,height:r}=n,s=n.threshold;n.thresholdValue&&(Uo.log.deprecated("thresholdValue","threshold")(),s=n.thresholdValue);let a=e<0,l=e>=i-1,c=o<0,g=o>=r-1,f=a||l||c||g,d={},p={};a||g?p.top=0:(d.top=t[(o+1)*i+e],p.top=yt(d.top,s)),l||g?p.topRight=0:(d.topRight=t[(o+1)*i+e+1],p.topRight=yt(d.topRight,s)),l||c?p.right=0:(d.right=t[o*i+e+1],p.right=yt(d.right,s)),a||c?p.current=0:(d.current=t[o*i+e],p.current=yt(d.current,s));let{top:x,topRight:h,right:A,current:S}=p,y=-1;Number.isFinite(s)&&(y=x<<3|h<<2|A<<1|S),Array.isArray(s)&&(y=x<<6|h<<4|A<<2|S);let _=0;return f||(_=yt((d.top+d.topRight+d.right+d.current)/4,s)),{code:y,meanCode:_}}function se(n){let{gridOrigin:t,cellSize:e,x:o,y:i,code:r,meanCode:s,type:a=Y.ISO_LINES}=n,l={...dr,...n.thresholdData},c=a===Y.ISO_BANDS?Bo[r]:Ro[r];Array.isArray(c)||(c=c[s]);let g=l.zIndex*l.zOffset,f=(o+1)*e[0],d=(i+1)*e[1],p=t[0]+f,x=t[1]+d;if(a===Y.ISO_BANDS){let A=[];return c.forEach(S=>{let y=[];S.forEach(_=>{let b=p+_[0]*e[0],O=x+_[1]*e[1];y.push([b,O,g])}),A.push(y)}),A}let h=[];return c.forEach(A=>{A.forEach(S=>{let y=p+S[0]*e[0],_=x+S[1]*e[1];h.push([y,_,g])})}),h}function zo({thresholdData:n,cellWeights:t,gridSize:e,gridOrigin:o,cellSize:i}){let r=[],s=[],a=e[0],l=e[1],c=0,g=0;for(let f of n){let{contour:d}=f,{threshold:p}=d;for(let x=-1;x<a;x++)for(let h=-1;h<l;h++){let{code:A,meanCode:S}=Wo({cellWeights:t,threshold:p,x,y:h,width:a,height:l}),y={type:Y.ISO_BANDS,gridOrigin:o,cellSize:i,x,y:h,width:a,height:l,code:A,meanCode:S,thresholdData:f};if(Array.isArray(p)){y.type=Y.ISO_BANDS;let _=se(y);for(let b of _)s[g++]={vertices:b,contour:d}}else{y.type=Y.ISO_LINES;let _=se(y);for(let b=0;b<_.length;b+=2)r[c++]={start:_[b],end:_[b+1],contour:d}}}}return{contourSegments:r,contourPolygons:s}}var Vo=M(E(),1);var Go=[255,255,255,255],pr=1,mr=1,hr={cellSize:{type:"number",min:1,max:1e3,value:1e3},getPosition:{type:"accessor",value:n=>n.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:mr}],optional:!0,compare:3},zOffset:.005},Ho="positions",xr={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},kt=class extends w{initializeState(){super.initializeAggregationLayer({dimensions:xr}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:T.SUM}}}),this.getAttributeManager().add({[Ho]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(t){super.updateState(t);let e=!1,{oldProps:o,props:i}=t,{aggregationDirty:r}=this.state;(o.contours!==i.contours||o.zOffset!==i.zOffset)&&(e=!0,this._updateThresholdData(t.props)),this.getNumInstances()>0&&(r||e)&&this._generateContours()}renderLayers(){let{contourSegments:t,contourPolygons:e}=this.state.contourData,o=this.getSubLayerClass("lines",jt.LineLayer),i=this.getSubLayerClass("bands",jt.SolidPolygonLayer),r=t&&t.length>0&&new o(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:a=>a.start,getTargetPosition:a=>a.end,getColor:a=>a.contour.color||Go,getWidth:a=>a.contour.strokeWidth||pr}),s=e&&e.length>0&&new i(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||Go});return[r,s]}updateAggregationState(t){let{props:e,oldProps:o}=t,{cellSize:i,coordinateSystem:r}=e,{viewport:s}=this.context,a=o.cellSize!==i,l=e.gpuAggregation;this.state.gpuAggregation!==e.gpuAggregation&&l&&!C.isSupported(this.context.device)&&(Vo.log.warn("GPU Grid Aggregation not supported, falling back to CPU")(),l=!1);let c=l!==this.state.gpuAggregation;this.setState({gpuAggregation:l});let{dimensions:g}=this.state,f=this.isAttributeChanged(Ho),{data:d,weights:p}=g,{boundingBox:x}=this.state;if(f&&(x=wt(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:x})),f||a){let{gridOffset:S,translation:y,width:_,height:b,numCol:O,numRow:B}=It(x,i,s,r);this.allocateResources(B,O),this.setState({gridOffset:S,boundingBox:x,translation:y,posOffset:y.slice(),gridOrigin:[-1*y[0],-1*y[1]],width:_,height:b,numCol:O,numRow:B})}let h=f||c||this.isAggregationDirty(t,{dimension:d,compareAll:l}),A=this.isAggregationDirty(t,{dimension:p});A&&this._updateAccessors(t),(h||A)&&this._resetResults(),this.setState({aggregationDataDirty:h,aggregationWeightsDirty:A})}_updateAccessors(t){let{getWeight:e,aggregation:o,data:i}=t.props,{count:r}=this.state.weights;r&&(r.getWeight=e,r.operation=T[o]),this.setState({getValue:Q(o,e,{data:i})})}_resetResults(){let{count:t}=this.state.weights;t&&(t.aggregationData=null)}_generateContours(){let{numCol:t,numRow:e,gridOrigin:o,gridOffset:i,thresholdData:r}=this.state,{count:s}=this.state.weights,{aggregationData:a}=s;a||(a=s.aggregationBuffer.readSyncWebGL(),s.aggregationData=a);let{cellWeights:l}=C.getCellData({countsData:a}),c=zo({thresholdData:r,cellWeights:l,gridSize:[t,e],gridOrigin:o,cellSize:[i.xOffset,i.yOffset]});this.setState({contourData:c})}_updateThresholdData(t){let{contours:e,zOffset:o}=t,i=e.length,r=new Array(i);for(let s=0;s<i;s++){let a=e[s];r[s]={contour:a,zIndex:a.zIndex||s,zOffset:o}}this.setState({thresholdData:r})}},_t=kt;(()=>{kt.layerName="ContourLayer"})(),(()=>{kt.defaultProps=hr})();var Ko=M(E(),1);var $o=M(E(),1);var N=M(E(),1),Xo=M(q(),1);var qo=M(q(),1);var ko=`#version 300 es
|
|
300
300
|
#define SHADER_NAME gpu-grid-cell-layer-vertex-shader
|
|
301
301
|
#define RANGE_COUNT 6
|
|
302
302
|
in vec3 positions;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "deck.gl layers that aggregate the input data into alternative representations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "9.0.
|
|
6
|
+
"version": "9.0.9",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@luma.gl/constants": "^9.0.
|
|
42
|
-
"@luma.gl/shadertools": "^9.0.
|
|
41
|
+
"@luma.gl/constants": "^9.0.11",
|
|
42
|
+
"@luma.gl/shadertools": "^9.0.11",
|
|
43
43
|
"@math.gl/web-mercator": "^4.0.0",
|
|
44
44
|
"d3-hexbin": "^0.2.1"
|
|
45
45
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"@luma.gl/core": "^9.0.0",
|
|
50
50
|
"@luma.gl/engine": "^9.0.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "ac5827ddda19cb79f80a599e6f5302e9075f9f6f"
|
|
53
53
|
}
|