(function(e){functionr(e,t){if(!t.steps)thrownewError("steps option missing");this.options=t,this.running=!1,this._tick=this._tick.bind(this),this._t0=+(newDate),this.callback=e,this._time=0,_.defaults(this.options,{animationDelay:0,maxDelta:.2,loop:!0}),this.rescale()}e.torque=e.torque||{};vart=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,16)},n=window.requestAnimationFrame||window.mozCancelAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){};r.prototype={start:function(){this.running=!0,t(this._tick)},isRunning:function(){returnthis.running},stop:function(){this.pause(),this.time(0)},time:function(e){if(!arguments.length)returnthis._time;this._time=e;vart=this.range(this.domain(this._time));this.callback(t)},toggle:function(){this.running?this.pause():this.start()},rescale:function(){returnthis.domainInv=torque.math.linear(this.options.animationDelay,this.options.animationDelay+this.options.animationDuration),this.domain=this.domainInv.invert(),this.range=torque.math.linear(0,this.options.steps),this.rangeInv=this.range.invert(),this.time(this._time),this},duration:function(e){returnarguments.length?(this.options.animationDuration=e,this.time()>e&&this.time(0),this.rescale(),this):this.options.animationDuration},steps:function(e){returnthis.options.steps=e,this.rescale()},step:function(e){if(arguments.length===0)returnthis.range(this.domain(this._time));this._time=this.domainInv(this.rangeInv(e))},pause:function(){this.running=!1,n(this._tick)},_tick:function(){vare=+(newDate),n=(e-this._t0)*.001;n=Math.min(this.options.maxDelta,n),this._t0=e,this._time+=n,this.time(this._time),this.step()>=this.options.steps&&(this._time=0),this.running&&t(this._tick)}},e.torque.Animator=r})(typeofexports=="undefined"?this:exports),function(e){e.torque=e.torque||{};vart={version:"1.0.0",style:{"comp-op":{css:"comp-op","default-value":"src-over","default-meaning":"add the current layer on top of other layers",doc:"Composite operation. This defines how this layer should behave relative to layers atop or below it.",type:["src","src-over","dst-over","src-in","dst-in","src-out","dst-out","src-atop","dst-atop","xor","darken","lighten"]}},layer:{"buffer-size":{"default-value":"0",type:"float","default-meaning":"No buffer will be used",doc:"Extra tolerance around the Layer extent (in pixels) used to when querying and (potentially) clipping the layer data during rendering"},"-torque-frame-count":{css:"-torque-frame-count","default-value":"128",type:"number","default-meaning":"the data is broken into 128 time frames",doc:"Number of animation steps/frames used in the animation. If the data contains a fewere number of total frames, the lesser value will be used."},"-torque-resolution":{css:"-torque-resolution","default-value":"2",type:"number","default-meaning":"",doc:"Spatial resolution in pixels. A resolution of 1 means no spatial aggregation of the data. Any other resolution of N results in spatial aggregation into cells of NxN pixels. The value N must be power of 2"},"-torque-animation-duration":{css:"-torque-animation-duration","default-value":"30",type:"number","default-meaning":"the animation lasts 30 seconds",doc:"Animation duration in seconds"},"-torque-aggregation-function":{css:"-torque-aggregation-function","default-value":"count(cartodb_id)",type:"string","default-meaning":"the value for each cell is the count of points in that cell",doc:"A function used to calculate a value from the aggregate data for each cell. See -torque-resolution"},"-torque-time-attribute":{css:"-torque-time-attribute","default-value":"time",type:"string","default-meaning":"the data column in your table that is of a time based type",doc:"The table column that contains the time information used create the animation"},"-torque-data-aggregation":{css:"-torque-data-aggregation","default-value":"linear",type:["cumulative"],"default-meaning":"previous values are discarded",doc:"Alinearanimation
.cumulative?"cumulative":"linear"},t="Map{";for(varnine)t+=n+":"+e[n]+";";returnt+"}"},_fetchMap:function(e){varn=this,r={},i=this._tilerHost()+"/api/v1/map",s=this.options.named_map;s?i=this._tilerHost()+"/api/v1/map/named/"+s.name+"/jsonp":r={version:"1.0.1",stat_tag:this.options.stat_tag||"torque",layers:[{type:"torque",options:{cartocss_version:"1.0.0",cartocss:this._generateCartoCSS(),sql:this.getSQL()}}]};varo=this._extraParams();o&&(o=o.replace("api_key=","map_key=")),i=i+"?config="+encodeURIComponent(JSON.stringify(r))+"&callback=?"+(o?"&"+o:"");varu=Profiler.metric("torque.provider.windshaft.layergroup.time").start();t.net.jsonp(i,function(e){u.end();if(e){vart=Object.keys(e.metadata.torque)[0],r=e.metadata.torque[t];for(variinr)n.options[i]=r[i];if(e.cdn_url){vars=n.options.cdn_url=n.options.cdn_url||{};s.http=e.cdn_url.http||s.http,s.https=e.cdn_url.https||s.https}n.templateUrl=n.url()+"/api/v1/map/"+e.layergroupid+"/"+t+"/{z}/{x}/{y}.json.torque",n._setReady(!0)}elseProfiler.metric("torque.provider.windshaft.layergroup.error").inc()},{callbackName:n.options.instanciateCallback})}},t.providers.windshaft=u}(typeofexports=="undefined"?this:exports),function(e){functionr(e,t,n){functiono(){r.removeChild(i),clearTimeout(u),deletewindow[s]}n=n||{},n.timeout=n.timeout===undefined?1e4:n.timeout;varr=document.getElementsByTagName("head")[0],i=document.createElement("script"),s=n.callbackName||"torque_"+Date.now();window[s]=function(){o(),t.apply(window,arguments)};varu=setTimeout(function(){o(),t.call(window,null)},n.timeout);e=e.replace("callback=?","callback="+s),i.type="text/javascript",i.src=e,i.async=!0,setTimeout(function(){r.appendChild(i)},0)}functioni(e,t,r){functiono(){vare=s.status,n,i=r.responseType==="arraybuffer"?s.response:s.responseText;!e&&i||e>=200&&e<300||e===304?t(s):t(null)}r=r||{method:"GET",data:null,responseType:"text"},n={url:e,callback:t};vari=XMLHttpRequest;window.XDomainRequest&&!("withCredentials"ini)&&/^(http(s)?:)?\/\//.test(e)&&(i=XDomainRequest);vars=newi;returns.open(r.method,e,!0),"onload"ins?s.onload=s.onerror=o:s.onreadystatechange=function(){s.readyState>3&&o()},s.onprogress=function(){},s.responseType=r.responseType,r.data&&(s.setRequestHeader("Content-type","application/json"),s.setRequestHeader("Accept","*")),s.send(r.data),s}functions(e,t,n){returni(e,n,{data:t,method:"POST"})}vart=e.torque=e.torque||{};t.net=t.net||{};varn=null;t.net={get:i,post:s,jsonp:r,lastCall:function(){returnn}}}(typeofexports=="undefined"?this:exports),function(e){functionn(e,n){e.fillStyle=n.fillStyle,e.strokStyle=n.strokStyle;varr=n["point-radius"];e.beginPath(),e.arc(0,0,r,0,t,!0,!0),e.closePath(),n.fillStyle&&(n.fillOpacity&&(e.globalAlpha=n.fillOpacity),e.fill()),e.globalAlpha=1,n.strokeStyle&&n.lineWidth&&(n.strokeOpacity&&(e.globalAlpha=n.strokeOpacity),n.lineWidth&&(e.lineWidth=n.lineWidth),e.strokeStyle=n.strokeStyle,e.globalAlpha>0&&e.stroke())}functionr(e,t){e.fillStyle=t.fillStyle,e.strokStyle=t.strokStyle;varn=t["point-radius"],r=n*2;t.fillStyle&&t.fillOpacity&&(e.globalAlpha=t.fillOpacity),e.fillRect(-n,-n,r,r),e.globalAlpha=1,t.strokeStyle&&t.lineWidth&&(t.strokeOpacity&&(e.globalAlpha=t.strokeOpacity),t.lineWidth&&(e.lineWidth=t.lineWidth),e.strokeStyle=t.strokeStyle,e.globalAlpha>0&&e.strokeRect(-n,-n,r,r))}functioni(e,t){varn=t["point-file"]||t["marker-file"],r=n.height/n.width,i=t["point-radius"]||n.width,s=t["point-radius"]||t["marker-height"]||i*r;e.drawImage(n,0,0,i,s)}e.torque=e.torque||{};vart=Math.PI*2;e.torque.cartocss=e.torque.cartocss||{},e.torque.cartocss={renderPoint:n,renderSprite:i,renderRectangle:r}}(typeofexports=="undefined"?this:exports),function(e){functionr(e,t){if(!e)thrownewError("canvas can't be undefined");this.options=t,this._canvas=e,this._ctx=e.getContext("2d"),this._sprites=[],this._shader=null,this.setCartoCSS(this.options.cartocss||n)}e.torque=e.torque||{},e.torque.renderer=e.torque.renderer||{};vart=Math.PI*2,n=["#layer {"," marker-fill: #662506;"," marker-width: 4;","[value>1]{marker-fill:#FEE391;
.provider.setSQL)thrownewError("this provider does not support SQL");returnthis.provider.setSQL(e),this._reloadTiles(),this},setBlendMode:function(e){this.renderer.setBlendMode(e),this.redraw()},setSteps:function(e){this.provider.setSteps(e),this._reloadTiles()},setColumn:function(e,t){this.provider.setColumn(e,t),this._reloadTiles()},getTimeBounds:function(){returnthis.provider&&this.provider.getKeySpan()},clear:function(){vare=this.getCanvas();e.width=e.width},render:function(){if(this.hidden)return;vare,t,n,r=this.getCanvas();r.width=r.width;vari=r.getContext("2d");for(einthis._tiles)t=this._tiles[e],t&&(n=this.getTilePos(t.coord),i.setTransform(1,0,0,1,n.x,n.y),this.renderer.renderTile(t,this.key,n.x,n.y))},setKey:function(e,t){this.key=e,this.animator.step(e),this.redraw(t&&t.direct),this.fire("change:time",{time:this.getTime(),step:this.key})},setStep:function(e){if(e===undefined||e.length!==undefined)thrownewError("setTime only accept scalars");this.setKey(e)},stepToTime:function(e){vart=this.provider.getKeySpan(),n=t.start+(t.end-t.start)*(e/this.provider.getSteps());returnnewDate(n)},getStep:function(){returnthis.key},getTime:function(){returnthis.stepToTime(this.key)},getTimeSpan:function(){vare=this.provider.getKeySpan()},setCartoCSS:function(e){if(!this.renderer)thrownewError("renderer is not valid");vart=(newcarto.RendererJS).render(e);this.renderer.setShader(t);varn=torque.common.TorqueLayer.optionsFromLayer(t.findLayer({name:"Map"}));returnthis.provider.setCartoCSS&&this.provider.setCartoCSS(e),this.provider.setOptions(n)&&this._reloadTiles(),_.extend(this.options,n),n.animationDuration&&this.animator.duration(n.animationDuration),this.redraw(),this},getActivePointsBBox:function(e){vart=[];for(varninthis._tiles){varr=this._tiles[n];t=t.concat(this.renderer.getActivePointsBBox(r,e))}returnt}}));