{"size": 5213, "ext": "js", "max_stars_repo_path": "public/3.12compact/esri/layers/HeatmapManager.js", "max_stars_repo_name": "muhamadanjar/rth", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/3.12compact/esri/layers/HeatmapManager.js", "max_issues_repo_name": "muhamadanjar/rth", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/3.12compact/esri/layers/HeatmapManager.js", "max_forks_repo_name": "muhamadanjar/rth", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 401.0, "max_line_length": 526, "alphanum_fraction": 0.7715327067}
// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.12/esri/copyright.txt for details.
//>>built
define("esri/layers/HeatmapManager","dojo/_base/declare dojo/_base/lang dojo/on dojo/aspect dojo/_base/array require ../kernel ../sniff ../geometry/Point ./MapImageLayer ./MapImage ./FeatureLayer ../renderers/HeatmapRenderer ../tasks/query".split(" "),function(f,n,E,s,t,u,v,w,x,y,z,A,r,B){function C(){}function D(b){var a=b.layer;return{geometry:b.geometry,attributes:b.attributes,getLayer:function(){return a}}}f=f(null,{declaredClass:"esri.layers.HeatmapManager",heatmapRenderer:null,sourceLayer:null,
imageLayer:null,useTiles:!0,useWorker:!1,map:null,constructor:function(b){this.sourceLayer=b;this._hndls=[]},initialize:function(b){this.map=b;var a=this.sourceLayer,c=a.renderer;a.setDrawMode(!1);var a=this.imageLayer=new y({className:"heatmapImgLyr"}),d=this;this.heatmapRenderer=c instanceof r?c:(c.getRendererInfoByZoom(b.getZoom())||c.getRendererInfoByScale(b.getScale())).renderer;this.recalculateHeatmap=this.recalculateHeatmap.bind(this);this._removeRenderer=this._removeRenderer.bind(this);this._handleRendererChange=
this._handleRendererChange.bind(this);this._rendererChangeHandle=this.sourceLayer.on("renderer-change",this._handleRendererChange);b.addLayer(a);u(["../workers/heatmapCalculator"],function(a){d._calculator=new a(n.mixin({width:d.map.width,height:d.map.height},d._getOptions()));d._setupRenderer();d.heatmapRenderer.getStats=function(a){return d._calculator.calculateStats(a||1)};d.heatmapRenderer.getHistogramData=function(a,b){return d._calculator.getHistogramData(a,b)}})},destroy:function(){this._removeHandlers();
this.map.removeLayer(this.imageLayer);this._rendererChangeHandle.remove();this._rendererChangeHandle=this.sourceLayer=this.imageLayer=this.map=this.heatmapRenderer=this._hndls=null},_handleRendererChange:function(b){var a=b.renderer,c=a instanceof r;this.heatmapRenderer?c?this.heatmapRenderer=a:this._removeRenderer(b):c&&(this.heatmapRenderer=a,this.sourceLayer&&this.map&&this._setupRenderer())},_setupRenderer:function(){var b=this._hndls,a=this.sourceLayer,c=this.map,d=this;a._originalDraw=a._draw;
a._draw=C;a._div.clear();setTimeout(this._resetGraphics.bind(this),250);b.push(a.on("update-end",function(a){d.recalculateHeatmap()}));b.push(a.on("suspend",function(a){d.imageLayer.suspend()}));b.push(a.on("resume",function(a){d.imageLayer.resume()}));b.push(s.after(a,"redraw",this.recalculateHeatmap));b.push(c.on("layer-remove",function(b){b.layer==a&&(c.removeLayer(d.imageLayer),d._removeRenderer({target:a}))}));a.mode!==A.MODE_ONDEMAND&&(b.push(c.on("resize, pan-end",function(a){setTimeout(d.recalculateHeatmap,
16)})),b.push(c.on("zoom-end",function(b){setTimeout(function(){a._getRenderer().isInstanceOf(r)&&d.recalculateHeatmap()},16)})));this.imageLayer.suspended&&this.imageLayer.resume();a.graphics&&a.graphics.length&&this.recalculateHeatmap()},_removeRenderer:function(b){var a=b.target;a._draw=a._originalDraw;delete a._originalDraw;a.setDrawMode(!0);this._removeHandlers();this._hndls=[];a.renderer!=b.renderer&&a.renderer.getRendererInfo?(this.heatmapRenderer=null,this.imageLayer.suspend()):(a.redraw(),
this.destroy())},recalculateHeatmap:function(){this._calculator?this._doMainCalculation():this._calculatorClient&&this._doWorkerCalculation()},_doWorkerCalculation:function(){},_doMainCalculation:function(){var b=this.sourceLayer,a=this.imageLayer,c=this.map,d=this.heatmapRenderer,p=this.map.extent,f=this.map.width,g=this.map.height,h=this._calculator,l=this,k=function(e){e=l._getScreenPoints(e.features,c,b);e=h.calculateImageData(n.mixin({screenPoints:e,mapinfo:{extent:[p.xmin,p.ymin,p.xmax,p.ymax],
resolution:c.getResolution()},width:f,height:g},l._getOptions()));e=d.getSymbol(D({geometry:c.extent,attributes:{size:[f,g],imageData:e},layer:b}));e=new z({extent:c.extent,href:e.url});a.addImage(e);setTimeout(function(){var b=a._mapImages.slice(0,-1),c=b.length;if(1E3<c)b=a._mapImages[c],a.removeAllImages(),a.addImage(b);else for(;c--&&b[c];)a.removeImage(b[c])},250)},q={geometry:c.extent,timeExtent:c.timeExtent,spatialRelationship:B.SPATIAL_REL_INTERSECTS};null!=b._canDoClientSideQuery(q)?b.queryFeatures(q,
k):k({features:b.graphics})},_getScreenPoints:function(b,a,c){var d=[],f=b.length,n=0,g=0,h,l=new x(a.extent.xmin,a.extent.ymax,a.spatialReference),k=a.toScreen(l),q=k.x,k=k.y,e=a.getResolution(),m;for(a.extent._parts&&(m=t.map(a.extent._parts,function(b){return c._intersects(a,b.extent)[0]}));f--;)g=b[f],g.geometry&&(h={x:Math.ceil((g.geometry.x-l.x)/e+q),y:Math.floor((l.y-g.geometry.y)/e-k),attributes:g.attributes},m&&(g=1<m.length&&h.x<-m[0]?m[1]:m[0],h.x+=g),d[n++]=h);return d},_removeHandlers:function(){for(var b=
this._hndls.length;b--;)this._hndls[b].remove()},_getOptions:function(){var b=this.heatmapRenderer;return{blurRadius:b.blurRadius,gradient:b.gradient,maxPixelIntensity:b.maxPixelIntensity,minPixelIntensity:b.minPixelIntensity,field:b.field}},_resetGraphics:function(){for(var b=this.sourceLayer.graphics,a=b.length,c;a--;)c=b[a],c._shape=c._offsets=void 0}});w("extend-esri")&&n.setObject("layers.HeatmapManager",f,v);return f});