!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.torque=e()}}(function(){var e,t,n;return function i(e,t,n){function r(o,u){if(!t[o]){if(!e[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(s)return s(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return r(n?n:t)},l,l.exports,i,e,t,n)}return t[o].exports}var s=typeof require=="function"&&require;for(var o=0;o=t)throw new Error("start must be smaller than end");this.start=e,this.end=t};r.prototype={diff:function(){return this.end-this.start},isLast:function(e){return(e|0)===this.end}},t.exports=r},{}],2:[function(e,t,n){(function(n){function u(e,t){if(!t.steps)throw new Error("steps option missing");this.options=t,this.running=!1,this._tick=this._tick.bind(this),this._t0=+(new Date),this.callback=e,this._time=0,this.itemsReady=!1,this.options=r.extend({animationDelay:0,maxDelta:.2,loop:t.loop===undefined?!0:t.loop},this.options),this.steps(t.steps)}var r=e("./"),i=e("./animator-steps-range"),s=n.requestAnimationFrame||n.mozRequestAnimationFrame||n.webkitRequestAnimationFrame||n.msRequestAnimationFrame||function(e){return n.setTimeout(e,1e3/60)},o=n.cancelAnimationFrame||n.mozCancelAnimationFrame||n.webkitCancelAnimationFrame||n.msCancelAnimationFrame||function(e){clearTimeout(e)};u.prototype={start:function(){this.running=!0,s(this._tick),this.options.onStart&&this.options.onStart(),this.stepsRange().diff()===1&&(this.running=!1)},isRunning:function(){return this.running},stop:function(){this.pause(),this.time(this.stepsRange().start),this.options.onStop&&this.options.onStop()},time:function(e){if(!arguments.length)return this._time;this._time=e;var t=this.range(this.domain(this._time));this.callback(t)},toggle:function(){this.running?this.pause():this.start()},rescale:function(){return this.domainInv=r.math.linear(this.options.animationDelay,this.options.animationDelay+this.options.animationDuration),this.domain=this.domainInv.invert(),this.range=r.math.linear(0,this._defaultStepsRange.end),this.rangeInv=this.range.invert(),this.time(this._time),this.running?this.start():this.pause(),this},duration:function(e){return arguments.length?(this.options.animationDuration=e,this.time()>e&&this.time(0),this.rescale(),this):this.options.animationDuration},steps:function(e){return this.options.steps=e,this._defaultStepsRange=new i(0,e),this.rescale()},stepsRange:function(e,t){if(arguments.length===2){if(ethis._defaultStepsRange.end)throw new Error("end must be within default steps range");this._customStepsRange=new i(e,t),this.options.onStepsRange&&this.options.onStepsRange();var n=this.step()|0;(nt)&&this.step(e)}return this._customStepsRange||this._defaultStepsRange},removeCustomStepsRange:function(){this._customStepsRange=undefined,this.options.onStepsRange&&this.options.onStepsRange()},step:function(e){if(arguments.length===0)return this.range(this.domain(this._time));this._time=this.domainInv(this.rangeInv(e))},pause:function(){this.running=!1,o(this._tick),this.options.onPause&&this.options.onPause()},_tick:function(){var e=+(new Date),t=(e-this._t0)*.001;t=Math.min(this.options.maxDelta,t),this._t0=e,this._time+=t;var n=this.stepsRange();n.isLast(this.step())&&(this.options.loop?this.step(n.start):(this.time(this.options.animationDuration),this.pause())),this.running&&(this.time(this._time),s(this._tick))}},t.exports=u}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./":11,"./animator-steps-range":1}],3:[function(e,t,n){var r={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-clear-color":{css:"-torque-clear-color",type:"color","default-value":"rgba(255, 255, 255, 0)","default-meaning":"full clear",doc:"color used to clear canvas on each frame"},"-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:"A linear animation will discard previous values while a cumulative animation will accumulate them until it restarts"}},symbolizers:{"*":{"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"]},opacity:{css:"opacity",type:"float",doc:"An alpha value for the style (which means an alpha applied to all features in separate buffer and then composited back to main buffer)","default-value":1,"default-meaning":"no separate buffer will be used and no alpha will be applied to the style after rendering"}},trail:{steps:{css:"trail-steps",type:"float","default-value":1,"default-meaning":"no trail steps",doc:"How many steps of trails are going to be rendered"}},polygon:{fill:{css:"polygon-fill",type:"color","default-value":"rgba(128,128,128,1)","default-meaning":"gray and fully opaque (alpha = 1), same as rgb(128,128,128)",doc:"Fill color to assign to a polygon"},"fill-opacity":{css:"polygon-opacity",type:"float",doc:"The opacity of the polygon","default-value":1,"default-meaning":"opaque"}},line:{stroke:{css:"line-color","default-value":"rgba(0,0,0,1)",type:"color","default-meaning":"black and fully opaque (alpha = 1), same as rgb(0,0,0)",doc:"The color of a drawn line"},"stroke-width":{css:"line-width","default-value":1,type:"float",doc:"The width of a line in pixels"},"stroke-opacity":{css:"line-opacity","default-value":1,type:"float","default-meaning":"opaque",doc:"The opacity of a line"},"stroke-linejoin":{css:"line-join","default-value":"miter",type:["miter","round","bevel"],doc:"The behavior of lines when joining"},"stroke-linecap":{css:"line-cap","default-value":"butt",type:["butt","round","square"],doc:"The display of line endings"}},markers:{file:{css:"marker-file",doc:"An SVG file that this marker shows at each placement. If no file is given, the marker will show an ellipse.","default-value":"","default-meaning":"An ellipse or circle, if width equals height",type:"uri"},opacity:{css:"marker-opacity",doc:"The overall opacity of the marker, if set, overrides both the opacity of both the fill and stroke","default-value":1,"default-meaning":"The stroke-opacity and fill-opacity will be used",type:"float"},"fill-opacity":{css:"marker-fill-opacity",doc:"The fill opacity of the marker","default-value":1,"default-meaning":"opaque",type:"float"},stroke:{css:"marker-line-color",doc:"The color of the stroke around a marker shape.","default-value":"black",type:"color"},"stroke-width":{css:"marker-line-width",doc:"The width of the stroke around a marker shape, in pixels. This is positioned on the boundary, so high values can cover the area itself.",type:"float"},"stroke-opacity":{css:"marker-line-opacity","default-value":1,"default-meaning":"opaque",doc:"The opacity of a line",type:"float"},fill:{css:"marker-fill","default-value":"blue",doc:"The color of the area of the marker.",type:"color"},"marker-type":{css:"marker-type",type:["rectangle","ellipse"],"default-value":"ellipse",doc:"The default marker-type. If a SVG file is not given as the marker-file parameter, the renderer provides either an rectangle or an ellipse (a circle if height is equal to width)"},width:{css:"marker-width","default-value":10,doc:"The width of the marker, if using one of the default types.",type:"float"}},point:{file:{css:"point-file",type:"uri",required:!1,"default-value":"none",doc:"Image file to represent a point"},opacity:{css:"point-opacity",type:"float","default-value":1,"default-meaning":"Fully opaque",doc:"A value from 0 to 1 to control the opacity of the point"}}},colors:{aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50],transparent:[0,0,0,0]}};t.exports={version:{latest:r,"1.0.0":r}}},{}],4:[function(e,t,n){(function(n){function i(){}var r=n.carto||e("carto");i.prototype={},i.optionsFromLayer=function(e){var t={};if(!e)return t;var n={"buffer-size":"buffer-size","-torque-frame-count":"steps","-torque-resolution":"resolution","-torque-animation-duration":"animationDuration","-torque-aggregation-function":"countby","-torque-time-attribute":"column","-torque-data-aggregation":"data_aggregation"};for(var r in n){var i=e.eval(r);if(i!==undefined){var s=n[r];t[s]=i}}return t},i.optionsFromCartoCSS=function(e){var t=(new r.RendererJS).render(e),n=t.findLayer({name:"Map"});return i.optionsFromLayer(n)},t.exports.TorqueLayer=i}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{carto:undefined}],5:[function(e,t,n){(function(e){function r(){var e=arguments,t=e[0];for(var n=1;ni&&(n.x-=i),this.canvas.style[r.CSS_TRANSFORM_]="translate("+Math.round(n.x)+"px,"+Math.round(n.y)+"px)",this.scheduleUpdate()},r.prototype.update_=function(){this.requestAnimationFrameId_=null;if(!this.isAdded_)return;this.isAnimated_&&this.scheduleUpdate(),this.needsResize_&&this.resizeHandler_&&(this.needsResize_=!1,this.resizeHandler_()),this.updateHandler_&&this.updateHandler_()},r.prototype.getTopLeft=function(){return this.topLeft_},r.prototype.scheduleUpdate=function(){this.isAdded_&&!this.requestAnimationFrameId_&&(this.requestAnimationFrameId_=this.requestAnimFrame_.call(window,this.requestUpdateFunction_))},t.exports=r},{}],7:[function(e,t,n){function r(e,t){this.tileSize=new google.maps.Size(256,256),this.maxZoom=19,this.name="Tile #s",this.alt="Canvas tile layer",this.tiles={},this.canvas_setup=e,this.render=t,t||(this.render=e)}r.prototype.create_tile_canvas=function(e,t,n){var r=n.createElement("canvas"),i=n.createElement("canvas");r.style.border=i.style.border="none",r.style.margin=i.style.margin="0",r.style.padding=i.style.padding="0";var s=r.getContext("2d");s.width=r.width=this.tileSize.width,s.height=r.height=this.tileSize.height;var o=i.getContext("2d");i.width=o.width=this.tileSize.width,i.height=o.height=this.tileSize.height;var u=e.x+"_"+e.y+"_"+t;return r.setAttribute("id",u),i.setAttribute("id",u),u in this.tiles&&delete this.tiles[u],this.tiles[u]={canvas:r,ctx:s,hit_canvas:i,hit_ctx:o,coord:e,zoom:t,primitives:null},this.canvas_setup&&this.canvas_setup(this.tiles[u],e,t),r},r.prototype.each=function(e){for(var t in this.tiles){var n=this.tiles[t];e(n)}},r.prototype.recreate=function(){for(var e in this.tiles){var t=this.tiles[e];this.canvas_setup(t,t.coord,t.zoom)}},r.prototype.redraw_tile=function(e){this.render(e,e.coord,e.zoom)},r.prototype.redraw=function(){for(var e in this.tiles){var t=this.tiles[e];this.render(t,t.coord,t.zoom)}},r.prototype.getTile=function(e,t,n){return this.create_tile_canvas(e,t,n)},r.prototype.releaseTile=function(e){var t=e.getAttribute("id");delete this.tiles[t]},t.exports=r},{}],8:[function(e,t,n){function r(){}r.prototype={_initTileLoader:function(e,t){this._map=e,this._projection=t,this._tiles={},this._tilesLoading={},this._tilesToLoad=0,this._updateTiles=this._updateTiles.bind(this),this._listeners=[],this._listeners.push(google.maps.event.addListener(this._map,"dragend",this._updateTiles),google.maps.event.addListener(this._map,"zoom_changed",this._updateTiles)),this.tileSize=256,this._updateTiles()},_removeTileLoader:function(){this._listeners.forEach(function(e){google.maps.event.removeListener(e)}),this._removeTiles()},_removeTiles:function(){for(var e in this._tiles)this._removeTile(e)},_reloadTiles:function(){this._removeTiles(),this._updateTiles()},_updateTiles:function(){if(!this._map)return;var e=this._map.getBounds(),t=this._map.getZoom(),n=this.tileSize,r=1<t.x||it.y)&&this._removeTile(s))},_removeTile:function(e){this.onTileRemoved&&this.onTileRemoved(this._tiles[e]),delete this._tiles[e],delete this._tilesLoading[e]},_tileKey:function(e){return e.x+":"+e.y+":"+e.zoom},_tileShouldBeLoaded:function(e){var t=this._tileKey(e);return!(t in this._tiles)&&!(t in this._tilesLoading)},_tileLoaded:function(e,t){this._tilesToLoad--;var n=e.x+":"+e.y+":"+e.zoom;this._tiles[n]=t,delete this._tilesLoading[n],this._tilesToLoad===0&&this.onTilesLoaded&&this.onTilesLoaded()},getTilePos:function(e){var t=1<=0&&a>=0&&u=0&&this.cancelAnimationFrame.call(window,this.currentAnimationFrame),this.currentAnimationFrame=this.requestAnimationFrame.call(window,this.render)},redraw:function(e){var t=L.DomUtil.getPosition(this._map.getPanes().mapPane);t&&L.DomUtil.setPosition(this._canvas,{x:-t.x,y:-t.y}),e?this.render():this._render()},onResize:function(){},render:function(){throw new Error("render function should be implemented")}})},{"./leaflet_tileloader_mixin":14}],13:[function(e,t,n){typeof L!="undefined"&&e("./torque")},{"./torque":15}],14:[function(e,t,n){L.Mixin.TileLoader={_initTileLoader:function(){this._tilesLoading={},this._tilesToLoad=0,this._map.on({moveend:this._updateTiles},this),this._updateTiles()},_removeTileLoader:function(){this._map.off({moveend:this._updateTiles},this),this._removeTiles()},_updateTiles:function(){if(!this._map)return;var e=this._map.getPixelBounds(),t=this._map.getZoom(),n=this.options.tileSize;if(t>this.options.maxZoom||te.max.x||re.max.y)&&this._removeTile(s))},_removeTile:function(e){this.fire("tileRemoved",this._tiles[e]),delete this._tiles[e],delete this._tilesLoading[e]},_tileKey:function(e){return e.x+":"+e.y+":"+e.zoom},_tileShouldBeLoaded:function(e){var t=this._tileKey(e);return!(t in this._tiles)&&!(t in this._tilesLoading)},_tileLoaded:function(e,t){this._tilesToLoad--;var n=e.x+":"+e.y+":"+e.zoom;this._tiles[n]=t,delete this._tilesLoading[n],this._tilesToLoad===0&&this.fire("tilesLoaded")},getTilePos:function(e){e=new L.Point(e.x,e.y);var t=this._map._getTopLeftPoint(this._map.getCenter()),n=this.options.tileSize;return e.multiplyBy(n).subtract(t)},_addTilesFromCenterOut:function(e){var t=[],n=e.getCenter(),r=this._map.getZoom();r=Math.round(r);var i,s,o;for(i=e.min.y;i<=e.max.y;i++)for(s=e.min.x;s<=e.max.x;s++)o=new L.Point(s,i),o.zoom=r,this._tileShouldBeLoaded(o)&&t.push(o);var u=t.length;if(u===0)return;t.sort(function(e,t){return e.distanceTo(n)-t.distanceTo(n)}),this._tilesToLoad+=u;for(s=0;s0&&l>0&&o.getContext("2d").drawImage(this.getCanvas(),u,a,f,l,u-n.x,a-n.y,f,l)}}}this.prevRenderedKey=this.getKey()},setKey:function(e,t){this.setKeys([e],t)},getKeys:function(){return this.keys},setKeys:function(e,t){this.keys=e,this.animator.step(this.getKey()),this._clearTileCaches(),this.redraw(t&&t.direct),this.fire("change:time",{time:this.getTime(),step:this.getKey(),start:this.getKey(),end:this.getLastKey()})},getKey:function(){return this.keys[0]},getLastKey:function(){return this.keys[this.keys.length-1]},setStep:function(e){if(e===undefined||e.length!==undefined)throw new Error("setTime only accept scalars");this.setKey(e)},renderRange:function(e,t){this.pause();var n=[];for(var r=e;r<=t;r++)n.push(r);this.setKeys(n)},resetRenderRange:function(){this.stop(),this.play()},stepToTime:function(e){var t=this.provider.getKeySpan(),n=t.start+(t.end-t.start)*(e/this.provider.getSteps());return new Date(n)},timeToStep:function(e){typeof e=="Date"&&(e=e.getTime());if(!this.provider)return 0;var t=this.provider.getKeySpan(),n=this.provider.getSteps()*(e-t.start)/(t.end-t.start);return n},getStep:function(){return this.getKey()},getTime:function(){return this.stepToTime(this.getKey())},getTimeSpan:function(){return this.provider.getKeySpan()},setCartoCSS:function(e){if(!this.renderer)throw new Error("renderer is not valid");if(this.provider&&this.provider.options.named_map)return console.log("Torque layer: CartoCSS style on named maps is read-only"),!1;this.renderer.setCartoCSS(e,function(){var t=r.common.TorqueLayer.optionsFromLayer(this.renderer._shader.findLayer({name:"Map"}));return this.provider.setCartoCSS&&this.provider.setCartoCSS(e),this.provider.setOptions(t)&&this._reloadTiles(),r.extend(this.options,t),t.animationDuration&&this.animator.duration(t.animationDuration),this._clearCaches(),this.redraw(),this}.bind(this))},getActivePointsBBox:function(e){var t=[];for(var n in this._tiles){var r=this._tiles[n];t=t.concat(this.renderer.getActivePointsBBox(r,e))}return t},getValues:function(e){var t=[];e=e===undefined?this.getKey():e;var n,r;for(n in this._tiles)r=this._tiles[n],this.renderer.getValues(r,e,t);return t},getValueForPos:function(e,t,n){n=n===undefined?this.getKey():n;var r,i,s,o=null,u,a;for(r in this._tiles){i=this._tiles[r],s=this.getTilePos(i.coord),u=e-s.x,a=t-s.y,u>=0&&a>=0&&u=0&&this.cancelAnimationFrame.call(window,this.currentAnimationFrame),this.currentAnimationFrame=this.requestAnimationFrame.call(window,this.render)},ol.CanvasLayer.prototype.getCanvas=function(){return this._canvas},ol.CanvasLayer.prototype.getAttribution=function(){return this.options.attribution},ol.CanvasLayer.prototype.draw=function(){return this._render()},ol.CanvasLayer.prototype.redraw=function(e){e?this.render():this._render()},t.exports=ol.CanvasLayer},{"./ol_tileloader_mixin":20}],19:[function(e,t,n){typeof ol!="undefined"&&e("./torque")},{"./torque":21}],20:[function(e,t,n){ol.TileLoader=function(e,t){this._tileSize=e,this._tiles={},this._tilesLoading={},this._tilesToLoad=0,this._updateTiles=this._updateTiles.bind(this),this._tileGrid=ol.tilegrid.createXYZ({maxZoom:t,tileSize:e})},ol.TileLoader.prototype._initTileLoader=function(e){this._map=e,this._view=e.getView(),this._centerChangedId=this._view.on("change:center",function(e){this._updateTiles()},this),this._postcomposeKey=undefined,this._resolutionChangedId=this._view.on("change:resolution",function(e){this._currentResolution=this._view.getResolution();if(this._postcomposeKey)return;this.fire("mapZoomStart"),this._postcomposeKey=this._map.on("postcompose",function(e){e.frameState.viewState.resolution===this._currentResolution&&(this._updateTiles(),this._map.unByKey(this._postcomposeKey),this._postcomposeKey=undefined,this.fire("mapZoomEnd"))},this)},this),this._updateTiles()},ol.TileLoader.prototype._removeTileLoader=function(){this._view.unByKey(this._centerChangedId),this._view.unByKey(this._resolutionChangedId),this._removeTiles()},ol.TileLoader.prototype._removeTiles=function(){for(var e in this._tiles)this._removeTile(e)},ol.TileLoader.prototype._reloadTiles=function(){this._removeTiles(),this._updateTiles()},ol.TileLoader.prototype._updateTiles=function(){if(!this._map)return;var e=this._tileGrid.getZForResolution(this._view.getResolution()),t=this._view.calculateExtent(this._map.getSize()),n=this._requestTilesForExtentAndZ(t,e);this._removeOtherTiles(n)},ol.TileLoader.prototype._removeOtherTiles=function(e){var t,n,r,i,s,o=this._tileGrid.getZForResolution(this._view.getResolution());for(s in this._tiles)this._tiles.hasOwnProperty(s)&&(t=s.split(":"),n=parseInt(t[0],10),r=parseInt(t[1],10),i=parseInt(t[2],10),(i!==o||ne.maxX||-r-1e.maxY)&&this._removeTile(s))},ol.TileLoader.prototype._removeTile=function(e){this.fire("tileRemoved",this._tiles[e]),delete this._tiles[e],delete this._tilesLoading[e]},ol.TileLoader.prototype._tileKey=function(e){return e.x+":"+e.y+":"+e.zoom},ol.TileLoader.prototype._tileShouldBeLoaded=function(e){var t=this._tileKey(e);return!(t in this._tiles)&&!(t in this._tilesLoading)},ol.TileLoader.prototype._removeFromTilesLoading=function(e){this._tilesToLoad--;var t=this._tileKey(e);delete this._tilesLoading[t],this._tilesToLoad===0&&this.fire("tilesLoaded")},ol.TileLoader.prototype._tileLoaded=function(e,t){var n=this._tileKey(e);this._tiles[n]=t},ol.TileLoader.prototype.getTilePos=function(e){var t=this._tileGrid.getZForResolution(this._view.getResolution()),n=this._tileGrid.getTileCoordExtent([t,e.x,-e.y-1]),r=this._map.getPixelFromCoordinate([n[0],n[3]]);return{x:r[0],y:r[1]}},ol.TileLoader.prototype._requestTilesForExtentAndZ=function(e,t){var n=[],r=[];this._tileGrid.forEachTileCoord(e,t,function(e){r.push(e);var t={x:e[1],y:-e[2]-1,zoom:e[0]};this._tileShouldBeLoaded(t)&&n.push(t)}.bind(this));var i=n.length;if(i>0){this._tilesToLoad+=i;for(var s=0;s=0&&a>=0&&u1&&(i.new_value(this.name,this.count),this.count=0,this.start())}},i.metric=function(e){return new s(e)},t.exports=i},{}],23:[function(e,t,n){t.exports={json:e("./json"),JsonArray:e("./jsonarray"),windshaft:e("./windshaft"),tileJSON:e("./tilejson")}},{"./json":24,"./jsonarray":25,"./tilejson":26,"./windshaft":27}],24:[function(e,t,n){function a(e){for(var t=1;t>0),e.options.data_steps=t.num_steps>>0,e.options.step=e.options.step||1,e.options.bounds=[[t.ymin,t.xmin],[t.ymax,t.xmax]],e._setReady(!0)},{parseJSON:!0,no_cdn:!0})},{parseJSON:!0,no_cdn:!0})}},t.exports=f},{"../":11,"../profiler":22}],25:[function(e,t,n){function f(e,t){for(var n=1;n=0?t["marker-fill-opacity"]:1,e.globalAlpha>0&&e.fill()),t["marker-line-color"]&&t["marker-line-width"]&&t["marker-line-width"]>i&&(e.globalAlpha=t["marker-line-opacity"]>=0?t["marker-line-opacity"]:1,t["marker-line-width"]!==undefined&&(e.lineWidth=t["marker-line-width"]),e.strokeStyle=t["marker-line-color"],e.globalAlpha>0&&e.stroke())}function u(e,t){e.fillStyle=t["marker-fill"];var n=t["marker-width"],r=n*2;if(t["marker-fill"]){if(t["marker-fill-opacity"]!==undefined||t["marker-opacity"]!==undefined)e.globalAlpha=t["marker-fill-opacity"]||t["marker-opacity"];e.fillRect(-n,-n,r,r)}e.globalAlpha=1,t["marker-line-color"]&&t["marker-line-width"]&&(t["marker-line-opacity"]&&(e.globalAlpha=t["marker-line-opacity"]),t["marker-line-width"]&&(e.lineWidth=t["marker-line-width"]),e.strokeStyle=t["marker-line-color"],e.globalAlpha>0&&e.strokeRect(-n,-n,r,r))}function a(e,t,n){if(t.complete){if(n["marker-fill-opacity"]!==undefined||n["marker-opacity"]!==undefined)e.globalAlpha=n["marker-fill-opacity"]||n["marker-opacity"];e.drawImage(t,0,0,Math.min(t.width,s),Math.min(t.height,s))}}var r=Math.PI*2,i=.05,s=255;t.exports={renderPoint:o,renderSprite:a,renderRectangle:u,MAX_SPRITE_RADIUS:s}},{}],29:[function(e,t,n){function s(e){this.tiles=e}var r=e("d3"),i=e("turf-jenks");t.exports=s,s.prototype.getName=function(){return"TorqueDataSource"},s.prototype.getRamp=function(e,t,n,i){var s=[],o=null,u=Object.keys(this.tiles).map(function(e){return this.tiles[e].renderData}.bind(this)).reduce(function(e,t,n){for(var n=0;ns[length-1]})))}}else o=new Error("Quantification method "+n+" is not supported");i(o,s)}},{d3:undefined,"turf-jenks":undefined}],30:[function(e,t,n){t.exports={cartocss:e("./cartocss_render"),Point:e("./point"),Rectangle:e("./rectangle")}},{"./cartocss_render":28,"./point":31,"./rectangle":32}],31:[function(e,t,n){(function(n){function p(e){return h[e]||e}function d(e,t){if(!e)throw new Error("canvas can't be undefined");this.options=t,this.layer=t.layer,this._canvas=e,this._ctx=e.getContext("2d"),this._sprites=[],this._shader=null,this._icons={},this._iconsToLoad=0,this._filters=new u(this._canvas,{canvasClass:t.canvasClass}),this.style=this.options.cartocss||c,this.setCartoCSS(this.style),this.TILE_SIZE=256,this._style=null,this._gradients={},this._forcePoints=!1}var r=e("../"),i=e("./cartocss_render"),s=e("../profiler"),o=n.carto||e("carto"),u=e("./torque_filters"),a=e("turbo-carto"),f=e("./datasource"),l="http://s3.amazonaws.com/com.cartodb.assets.static/error.svg",c=["#layer {"," marker-fill: #662506;"," marker-width: 4;"," [value > 1] { marker-fill: #FEE391; }"," [value > 2] { marker-fill: #FEC44F; }"," [value > 3] { marker-fill: #FE9929; }"," [value > 4] { marker-fill: #EC7014; }"," [value > 5] { marker-fill: #CC4C02; }"," [value > 6] { marker-fill: #993404; }"," [value > 7] { marker-fill: #662506; }","}"].join("\n"),h={difference:"difference",src:"source-over",exclusion:"exclusion",dst:"destination-in",multiply:"multiply",contrast:"contrast","src-over":"source-over",screen:"screen",invert:"invert","dst-over":"destination-over",overlay:"overlay","invert-rgb":"invert","src-in":"source-in",darken:"darken","dst-in":"destination-in",lighten:"lighten","src-out":"source-out","color-dodge":"color-dodge",hue:"hue","dst-out":"destination-out","color-burn":"color-burn",saturation:"saturation","src-atop":"source-atop","hard-light":"hard-light",color:"color","dst-atop":"destination-atop","soft-light":"soft-light",xor:"xor"};r.extend(d.prototype,r.Event,{clearCanvas:function(){if(this._Map){var e=this._canvas,t=this._Map["-torque-clear-color"],n=this._ctx;if(t==="rgba(255, 255, 255, 0)"||!t)n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,e.width,e.height),n.restore();else{n.setTransform(1,0,0,1,0,0);var r=this._Map["comp-op"];n.globalCompositeOperation=p(r)||r,n.fillStyle=t,n.fillRect(0,0,e.width,e.height)}}},setCanvas:function(e){this._canvas=e,this._ctx=e.getContext("2d")},setCartoCSS:function(e,t){var n=this;this.style=e;if(d.isTurboCarto(e)){var r=new f(n.layer._tiles);a(e,r,function(e,r){if(e)return t(e,null);n.setShader((new o.RendererJS).render(r)),n.layer.redraw(),n.layer.animator.start(),t&&t()})}else n.setShader((new o.RendererJS).render(e)),t&&t()},setShader:function(e){this._sprites=[],this._shader=e,this._Map=this._shader.getDefault().getStyle({},{zoom:0});var t=this._shader.getImageURLs();t.push(l),this._preloadIcons(t)},clearSpriteCache:function(){this._sprites=[]},generateSprite:function(e,t,n){var o=this,u=s.metric("torque.renderer.point.generateSprite").start(),a=e.getStyle({value:t},n);if(this._style===null||this._style!==a)this._style=a;var f=a["marker-width"];if(!f)return null;if(a["marker-opacity"]===0&&!a["marker-line-opacity"])return null;var l=this._createCanvas(),c=l.getContext("2d"),h=a["marker-file"]||a["point-file"],p=h&&this._qualifyURL(h);if(p&&this._iconsToLoad<=0&&this._icons[p]){var d=this._icons[p],v=Math.min(a["marker-width"]*2||d.width,i.MAX_SPRITE_RADIUS*2),m=Math.min((a["marker-height"]||v)*(d.width/d.height),i.MAX_SPRITE_RADIUS*2);l.width=c.width=v,l.height=c.height=m,c.scale(v/d.width,m/d.height),i.renderSprite(c,d,a)}else{var g=(a["marker-line-width"]||0)+f*2,y=c.width=l.width=c.height=l.height=Math.ceil(g);c.translate(y/2,y/2);var b=a["marker-type"];b&&b==="rectangle"?i.renderRectangle(c,a):i.renderPoint(c,a)}u.end(!0);if(r.flags.sprites_to_images){var w=this._createImage();return w.src=l.toDataURL(),w}return l},renderTile:function(e,t,n){if(e.error)return this._renderErrorTile(e),!1;if(this._iconsToLoad>0)return this.on("allIconsLoaded",function(){this.renderTile.apply(this,[e,t,n])}),!1;typeof t.length=="undefined"&&(t=[t]);var r=s.metric("torque.renderer.point.renderLayers").start(),i=this._shader.getLayers();for(var o=0,u=i.length;oe.maxDate&&(t=e.maxDate);var c=this.options.resolution*(this.TILE_SIZE/this.options.resolution-1),h=e.timeCount[t],d=this.options.resolution/2;if(h){var v=e.timeIndex[t];for(var m=0;m>1)+d,E=c-e.y[g]+d;f.drawImage(b,w,E-(b.height>>1))}}}}a.end(!0)},setBlendMode:function(e){this.options.blendmode=e},getActivePointsBBox:function(e,t){var n=[],i=new r.Mercator,s=this.options.resolution*(this.TILE_SIZE/this.options.resolution-1),o=e.timeCount[t],u=e.timeIndex[t];for(var a=0;a>1,a=this.options.resolution*(this.TILE_SIZE/this.options.resolution-1),f=e.timeCount[t],l=e.timeIndex[t];for(var c=0;c=0&&m=0&&g0&&!this._forcePoints){var n=Object.keys(e.reduce(function(e,n){var r=t._qualifyURL(n);return t._icons[r]||(e[r]=!0),e},{})),r=t._shader.getLayers().some(function(e){return typeof e.shader["image-filters"]!="undefined"});this._iconsToLoad+=n.length,n.forEach(function(e){t._icons[e]=null;var n=t._createImage();r&&(n.crossOrigin="Anonymous"),t._setImageSrc(n,e,function(i){i?(t._forcePoints=!0,t.clearSpriteCache(),t._iconsToLoad=0,t.fire("allIconsLoaded"),r&&console.info("Only CORS-enabled, or same domain image-files can be used in combination with image-filters"),console.error("Couldn't get marker-file "+e)):(t._icons[e]=n,t._iconsToLoad--,t._iconsToLoad<=0&&(t.clearSpriteCache(),t.fire("allIconsLoaded") ))})})}else this.fire("allIconsLoaded")},applyFilters:function(){if(this._style&&this._style["image-filters"]){function e(e){var t="";for(var n=0;n 10] { polygon-fill: #FFFF00; }"," [value > 100] { polygon-fill: #FFCC00; }"," [value > 1000] { polygon-fill: #FE9929; }"," [value > 10000] { polygon-fill: #FF6600; }"," [value > 100000] { polygon-fill: #FF3300; }","}"].join("\n"),s=Math.PI*2;o.prototype={setCartoCSS:function(e){this._cartoCssStyle=(new r.RendererJS).render(e);if(this._cartoCssStyle.getLayers().length>1)throw new Error("only one CartoCSS layer is supported");this._shader=this._cartoCssStyle.getLayers()[0].shader},setCanvas:function(e){if(!e)return;this._canvas=e,this._ctx=e.getContext("2d")},accumulate:function(e,t){var n=Profiler.metric("RectangleRender:accumulate").start(),r,i,s,o,u,a,f,l,c=this.options.resolution,h=256/c,p=new Float32Array(h*h);typeof t!="object"&&(t=[t]);for(u=0;u=200&&e<300||e===304||e===429?t(o):t(null)}r=r||{method:"GET",data:null,responseType:"text"},i={url:e,callback:t};var s=XMLHttpRequest;n.XDomainRequest&&!("withCredentials"in s)&&/^(http(s)?:)?\/\//.test(e)&&(s=XDomainRequest);var o=new s;return o.open(r.method,e,!0),"onload"in o?o.onload=o.onerror=u:o.onreadystatechange=function(){o.readyState>3&&u()},o.onprogress=function(){},o.responseType=r.responseType,r.data&&(o.setRequestHeader("Content-type","application/json"),o.setRequestHeader("Accept","*")),o.send(r.data),o}function u(e,t,n){return o(e,n,{data:t,method:"POST"})}var r=e("./core"),i=null;t.exports={get:o,post:u,jsonp:s,lastCall:function(){return i}}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"./core":5}]},{},[11])(11)});