torque/dist/torque.full.js

5 lines
150 KiB
JavaScript
Raw Normal View History

2014-05-22 23:25:22 +08:00
function require(e){var t=window.carto[e];return t||(t=window.carto[e.split("/")[1]]),t||(t=window.carto[e]),t||(t=window[e.split("/")[1]]),t||(t=window[e]),t}var assert={ok:function(e,t){t=t||"";if(!e)throw new Error("assertion failed",t)}};if(navigator.userAgent.indexOf("MSIE 8.0")!==-1||navigator.userAgent.indexOf("MSIE 7.0")!==-1)Object.defineProperty=function(e,t,n){e[t]=n.value};var carto_initialize=function(e,t,n){n()};window.carto=window.carto||{};var _mapnik_reference_latest={version:"2.1.1",style:{"filter-mode":{type:["all","first"],doc:"Control the processing behavior of Rule filters within a Style. If 'all' is used then all Rules are processed sequentially independent of whether any previous filters matched. If 'first' is used then it means processing ends after the first match (a positive filter evaluation) and no further Rules in the Style are processed ('first' is usually the default for CSS implementations on top of Mapnik to simplify translation from CSS to Mapnik XML)","default-value":"all","default-meaning":"All Rules in a Style are processed whether they have filters or not and whether or not the filter conditions evaluate to true."},"image-filters":{css:"image-filters","default-value":"none","default-meaning":"no filters",type:"functions",functions:[["agg-stack-blur",2],["emboss",0],["blur",0],["gray",0],["sobel",0],["edge-detect",0],["x-gradient",0],["y-gradient",0],["invert",0],["sharpen",0]],doc:"A list of image filters."},"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:["clear","src","dst","src-over","dst-over","src-in","dst-in","src-out","dst-out","src-atop","dst-atop","xor","plus","minus","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","contrast","invert","invert-rgb","grain-merge","grain-extract","hue","saturation","color","value"]},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"}},layer:{name:{"default-value":"",type:"string",required:!0,"default-meaning":"No layer name has been provided",doc:"The name of a layer. Can be anything you wish and is not strictly validated, but ideally unique in the map"},srs:{"default-value":"",type:"string","default-meaning":"No srs value is provided and the value will be inherited from the Map's srs",doc:"The spatial reference system definition for the layer, aka the projection. Can either be a proj4 literal string like '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' or, if the proper proj4 epsg/nad/etc identifier files are installed, a string that uses an id like: '+init=epsg:4326'"},status:{"default-value":!0,type:"boolean","default-meaning":"This layer will be marked as active and available for processing",doc:"A property that can be set to false to disable this layer from being processed"},minzoom:{"default-value":"0",type:"float","default-meaning":"The layer will be visible at the minimum possible scale",doc:"The minimum scale denominator that this layer will be visible at. A layer's visibility is determined by whether its status is true and if the Map scale >= minzoom - 1e-6 and scale < maxzoom + 1e-6"},maxzoom:{"default-value":"1.79769e+308",type:"float","default-meaning":"The layer will be visible at the maximum possible scale",doc:"The maximum scale denominator that this layer will be visible at. The default is the numeric limit of the C++ double type, which may vary slightly by system, but is likely a massive number like 1.79769e+308 and ensures that this layer will always be visible unless the value is reduced. A layer's visibility is determined by whether its status is true and if the Map scale >= minzoom - 1e-6 and scale < maxzoom + 1e-6
},"mesh-size":{css:"raster-mesh-size","default-value":16,"default-meaning":"Reprojection mesh will be 1/16 of the resolution of the source image",type:"unsigned",doc:"A reduced resolution mesh is used for raster reprojection, and the total image size is divided by the mesh-size to determine the quality of that mesh. Values for mesh-size larger than the default will result in faster reprojection but might lead to distortion."},"comp-op":{css:"raster-comp-op","default-value":"src-over","default-meaning":"add the current symbolizer on top of other symbolizer",doc:"Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.",type:["clear","src","dst","src-over","dst-over","src-in","dst-in","src-out","dst-out","src-atop","dst-atop","xor","plus","minus","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","contrast","invert","invert-rgb","grain-merge","grain-extract","hue","saturation","color","value"]}},point:{file:{css:"point-file",type:"uri",required:!1,"default-value":"none",doc:"Image file to represent a point"},"allow-overlap":{css:"point-allow-overlap",type:"boolean","default-value":!1,doc:"Control whether overlapping points are shown or hidden.","default-meaning":"Do not allow points to overlap with each other - overlapping markers will not be shown."},"ignore-placement":{css:"point-ignore-placement",type:"boolean","default-value":!1,"default-meaning":"do not store the bbox of this geometry in the collision detector cache",doc:"value to control whether the placement of the feature will prevent the placement of other features"},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"},placement:{css:"point-placement",type:["centroid","interior"],doc:"How this point should be placed. Centroid calculates the geometric center of a polygon, which can be outside of it, while interior always places inside of a polygon.","default-value":"centroid"},transform:{css:"point-transform",type:"functions",functions:[["matrix",6],["translate",2],["scale",2],["rotate",3],["skewX",1],["skewY",1]],"default-value":"","default-meaning":"No transformation",doc:"SVG transformation definition"},"comp-op":{css:"point-comp-op","default-value":"src-over","default-meaning":"add the current symbolizer on top of other symbolizer",doc:"Composite operation. This defines how this symbolizer should behave relative to symbolizers atop or below it.",type:["clear","src","dst","src-over","dst-over","src-in","dst-in","src-out","dst-out","src-atop","dst-atop","xor","plus","minus","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","contrast","invert","invert-rgb","grain-merge","grain-extract","hue","saturation","color","value"]}},text:{name:{css:"text-name",type:"expression",required:!0,"default-value":"",serialization:"content",doc:"Value to use for a text label. Data columns are specified using brackets like [column_name]"},"face-name":{css:"text-face-name",type:"string",validate:"font",doc:"Font name and style to render a label in",required:!0},size:{css:"text-size",type:"float","default-value":10,doc:"Text size in pixels"},"text-ratio":{css:"text-ratio",doc:"Define the amount of text (of the total) present on successive lines when wrapping occurs","default-value":0,type:"unsigned"},"wrap-width":{css:"text-wrap-width",doc:"Length of a chunk of text in characters before wrapping text","default-value":0,type:"unsigned"},"wrap-before":{css:"text-wrap-before",type:"boolean","default-value":!1,doc:"Wrap text before wrap-width is reached. If false, wrapped lines will be a bit longer than wrap-width."},"wrap-character":{css:"text-wrap-character",type:"string","default-value":" ",doc:"Use this character instead of a space to wrap long text."},spacing:{css:"text-spacing",type:"unsigned",doc:"Distance between repeated text labels on a line (aka. label-spacing)"},"character-
val>=n)return!1;if(t+">="in this&&this[t+">="].val>n)return!1;if(t+"<"in this&&this[t+"<"].val<=n)return null;if(t+"<="in this&&this[t+"<="].val<=n)return null;return!0}}}),Object.defineProperty(tree.Filterset.prototype,"add",{enumerable:!1,value:function(e){var t=e.key;switch(e.op){case"=":for(var n in this)this[n].key==t&&delete this[n];this[t+"="]=e;break;case"!=":this[t+"!="+e.val]=e;break;case"=~":this[t+"=~"+e.val]=e;break;case">":for(var n in this)this[n].key==t&&this[n].val<=e.val&&delete this[n];this[t+">"]=e;break;case">=":for(var n in this)this[n].key==t&&this[n].val<e.val&&delete this[n];t+"!="+e.val in this?(delete this[t+"!="+e.val],e.op=">",this[t+">"]=e):this[t+">="]=e;break;case"<":for(var n in this)this[n].key==t&&this[n].val>=e.val&&delete this[n];this[t+"<"]=e;break;case"<=":for(var n in this)this[n].key==t&&this[n].val>e.val&&delete this[n];t+"!="+e.val in this?(delete this[t+"!="+e.val],e.op="<",this[t+"<"]=e):this[t+"<="]=e}}}),function(e){e._getFontSet=function(t,n){var r=function(e){var n=e.join("");for(var r=0;r<t.effects.length;r++)if(n==t.effects[r].fonts.join(""))return t.effects[r]},i=!1;if(i=r(n))return i;var s=new e.FontSet(t,n);return t.effects.push(s),s},e.FontSet=function(t,n){this.fonts=n,this.name="fontset-"+t.effects.length},e.FontSet.prototype.toXML=function(e){return'<FontSet name="'+this.name+'">\n'+this.fonts.map(function(e){return' <Font face-name="'+e+'"/>'}).join("\n")+"\n</FontSet>"}}(require("../tree"));var tree=require("../tree");tree.FrameOffset=function(e,t,n){t=parseInt(t,10);if(t>tree.FrameOffset.max||t<=0)throw{message:"Only frame-offset levels between 1 and "+tree.FrameOffset.max+" supported.",index:n};if(e!=="=")throw{message:"only = operator is supported for frame-offset",index:n};return t},tree.FrameOffset.max=32,tree.FrameOffset.none=0,function(e){e.ImageFilter=function(t,n){this.is="imagefilter",this.filter=t,this.args=n||null},e.ImageFilter.prototype={eval:function(){return this},toString:function(){return this.args?this.filter+":"+this.args.join(","):this.filter}}}(require("../tree")),function(e){e.Invalid=function(t,n,r){this.chunk=t,this.index=n,this.type="syntax",this.message=r||"Invalid code: "+this.chunk},e.Invalid.prototype.eval=function(e){return e.error({chunk:this.chunk,index:this.index,type:"syntax",message:this.message||"Invalid code: "+this.chunk}),{is:"undefined"}}}(require("../tree")),function(e){e.Keyword=function(t){this.value=t;var n={transparent:"color","true":"boolean","false":"boolean"};this.is=n[t]?n[t]:"keyword"},e.Keyword.prototype={eval:function(){return this},toString:function(){return this.value}}}(require("../tree")),function(e){e.Layer=function(t){this.name=t.name,this.status=t.status,this.styles=t.styles,this.properties=t.properties||{},this.srs=t.srs,this.datasource=t.Datasource},e.Layer.prototype.toXML=function(){var e=[];for(var t in this.datasource)e.push('<Parameter name="'+t+'"><![CDATA['+this.datasource[t]+"]]></Parameter>");var n="";for(var t in this.properties)n+=" "+t+'="'+this.properties[t]+'"\n';return'<Layer name="'+this.name+'"\n'+n+(typeof this.status=="undefined"?"":' status="'+this.status+'"\n')+' srs="'+this.srs+'">\n '+this.styles.reverse().map(function(e){return"<StyleName>"+e+"</StyleName>"}).join("\n ")+"\n <Datasource>\n "+e.join("\n ")+"\n </Datasource>\n"+" </Layer>\n"}}(require("../tree")),function(e){e.Literal=function(t){this.value=t||"",this.is="field"},e.Literal.prototype={toString:function(){return this.value},eval:function(){return this}}}(require("../tree")),function(e){e.Operation=function(t,n,r){this.op=t.trim(),this.operands=n,this.index=r,this.is="operation"},e.Operation.prototype.eval=function(t){var n=this.operands[0].eval(t),r=this.operands[1].eval(t),i;return n.is==="undefined"||r.is==="undefined"?{is:"undefined",value:"undefined"}:(n instanceof e.Dimension&&r instanceof e.Color&&(this.op==="*"||this.op==="+"?(i=r,r=n,n=i):t.error({name:"OperationError",message:"Can't substract or divide a color from a number",index:this.index})),n instanceof e.Quoted&&r instance
:[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]}};e.torque["torque-reference"]={version:{latest:t,"1.0.0":t}}}(typeof exports=="undefined"?this:exports),function(e){function t(){}t.prototype={},t.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},t.optionsFromCartoCSS=function(e){var n=(new carto.RendererJS).render(e),r=n.findLayer({name:"Map"});return t.optionsFromLayer(r)},e.torque.common=torque.common||{},e.torque.common.TorqueLayer=t}(typeof exports=="undefined"?this:exports),function(e){e.torque=e.torque||{};var t={};t.on=function(e,t){var n=this._evt_callbacks=this._evt_callbacks||{},r=n[e]||(n[e]=[]);r.push(t)},t.trigger=function(e){var t=this._evt_callbacks&&this._evt_callbacks[e];for(var n=0;t&&n<t.length;++n)t[n].apply(this,Array.prototype.slice.call(arguments,1))},t.fire=t.trigger,t.off=function(e,t){var n=this._evt_callbacks&&this._evt_callbacks[e];if(n&&!t)return delete this._evt_callbacks[e],this;var r=[];for(var i=0;n&&i<n.length;++i)n[i]===t&&r.push(i);while((i=r.pop())!==undefined)n.splice(i,1)},t.callbacks=function(e){return this._evt_callbacks&&this._evt_callbacks[e]||[]},e.torque.Event=t,e.torque.types={Uint8Array:typeof window.Uint8Array!="undefined"?window.Uint8Array:Array,Uint32Array:typeof window.Uint32Array!="undefined"?window.Uint32Array:Array,Int32Array:typeof window.Int32Array!="undefined"?window.Int32Array:Array},e.torque.isBrowserSupported=function(){return!!document.createElement("canvas")}}(typeof exports=="undefined"?this:exports),typeof module!="undefined"&&(module.exports={cartocss_reference:require("./cartocss_reference").torque["torque-reference"]}),function(e){function t(e,t){return function(n){return Math.max(Math.min(n,t),e)}}function n(e,n){var r=t(0,1);return function(t){return r((t-e)/(n-e))}}function r(e,r){function s(t){return i(e*(1-t)+t*r)}var i=t(e,r);return s.invert=function(){return n(e,r)},s}e.torque=e.torque|
onRemove=function(){if(!this.isAdded_)return;this.isAdded_=!1,this.topLeft_=null,this.canvas.parentElement.removeChild(this.canvas),this.centerListener_&&(google.maps.event.removeListener(this.centerListener_),this.centerListener_=null),this.resizeListener_&&(google.maps.event.removeListener(this.resizeListener_),this.resizeListener_=null),this.requestAnimationFrameId_&&(this.cancelAnimFrame_.call(window,this.requestAnimationFrameId_),this.requestAnimationFrameId_=null)},CanvasLayer.prototype.resize_=function(){if(!this.isAdded_)return;var e=this.getMap(),t=e.getDiv().offsetWidth,n=e.getDiv().offsetHeight,r=this.canvas.width,i=this.canvas.height;if(r!==t||i!==n)this.canvas.width=t,this.canvas.height=n,this.canvas.style.width=t+"px",this.canvas.style.height=n+"px",this.needsResize_=!0,this.scheduleUpdate()},CanvasLayer.prototype.draw=function(){this.repositionCanvas_()},CanvasLayer.prototype.repositionCanvas_=function(){var e=this.getMap().getBounds();this.topLeft_=new google.maps.LatLng(e.getNorthEast().lat(),e.getSouthWest().lng());var t=this.getProjection(),n=t.fromLatLngToDivPixel(this.topLeft_),r=(1<<this.getMap().getZoom())*256;Math.abs(n.x)>r&&(n.x-=r),this.canvas.style[CanvasLayer.CSS_TRANSFORM_]="translate("+Math.round(n.x)+"px,"+Math.round(n.y)+"px)",this.scheduleUpdate()},CanvasLayer.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_()},CanvasLayer.prototype.getTopLeft=function(){return this.topLeft_},CanvasLayer.prototype.scheduleUpdate=function(){this.isAdded_&&!this.requestAnimationFrameId_&&(this.requestAnimationFrameId_=this.requestAnimFrame_.call(window,this.requestUpdateFunction_))}}if(typeof google!="undefined"&&typeof google.maps!="undefined"){function CanvasTileLayer(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)}CanvasTileLayer.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},CanvasTileLayer.prototype.each=function(e){for(var t in this.tiles){var n=this.tiles[t];e(n)}},CanvasTileLayer.prototype.recreate=function(){for(var e in this.tiles){var t=this.tiles[e];this.canvas_setup(t,t.coord,t.zoom)}},CanvasTileLayer.prototype.redraw_tile=function(e){this.render(e,e.coord,e.zoom)},CanvasTileLayer.prototype.redraw=function(){for(var e in this.tiles){var t=this.tiles[e];this.render(t,t.coord,t.zoom)}},CanvasTileLayer.prototype.getTile=function(e,t,n){return this.create_tile_canvas(e,t,n)},CanvasTileLayer.prototype.releaseTile=function(e){var t=e.getAttribute("id");delete this.tiles[t]}}(function(e){function t(){}if(typeof google=="undefined"||typeof google.maps=="undefined")return;t.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(){for(var e in this._listeners)google.maps.event.removeListener(this._listeners[e]);this._removeTiles()},_removeTiles:function(){for(var e in this._tiles)this._removeTi