5 lines
154 KiB
JavaScript
5 lines
154 KiB
JavaScript
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"},queryable:{"default-value":!1,type:"boolean","default-meaning":"The layer will not be available for the direct querying of data values",doc:"This property was added for GetFeatureInfo/WMS compatibility and is rarely used. It is off by default meaning that in a WMS context the layer will not be able to be queried unless the property is explicitly set to true"},"clear-label-cache":{"default-value":!1,type:"boolean","default-meaning":"The renderer's collision detector cache (used for avoiding duplicate labels and overlapping markers) will not be cleared immediately before processing this layer",doc:"This property, by default off, can be enabled to allow a user to clear the collision detector cache before a given layer is processed. This may be desirable to ensure that a given layers data shows up on the map even if it normally would not because of collisions with previously rendered labels or markers"},"group-by":{"default-value":"",type:"string","default-meaning":"No special layer grouping will be used during rendering",doc:"https://github.com/mapnik/mapnik/wiki/Grouped-rendering"},"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"},"maximum-extent":{"default-value":"none",type:"bbox","default-meaning":"No clipping extent will be used",doc:"An extent to be used to limit the bounds used to query this specific layer data during rendering. Should be minx, miny, maxx, maxy in the coordinates of the Layer."}},symbolizers:{"*":{"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"}},map:{"background-color":{css:"background-color","default-value":"none","default-meaning":"transparent",type:"color",doc:"Map Background color"},"background-image":{css:"background-image",type:"uri","default-value":"","default-meaning":"transparent",doc:"An image that is repeated below all features on a map as a background.",description:"Map Background image"},srs:{css:"srs",type:"string","default-value":"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs","default-meaning":"The proj4 literal of EPSG:4326 is assumed to be the Map's spatial reference and all data from layers within this map will be plotted using this coordinate system. If any layers do not declare an srs value then they will be assumed to be in the same srs as the Map and not transformations will be needed to plot them in the Map's coordinate space",doc:"Map spatial reference (proj4 string)"},"buffer-size":{css:"buffer-size","default-value":"0",type:"float","default-meaning":"No buffer will be used",doc:'Extra tolerance around the map (in pixels) used to ensure labels crossing tile boundaries are equally rendered in each tile (e.g. cut in each tile). Not intended to be used in combination with "avoid-edges".'},"maximum-extent":{css:"","default-value":"none",type:"bbox","default-meaning":"No clipping extent will be used",doc:"An extent to be used to limit the bounds used to query all layers during rendering. Should be minx, miny, maxx, maxy in the coordinates of the Map."},base:{css:"base","default-value":"","default-meaning":"This base path defaults to an empty string meaning that any relative paths to files referenced in styles or layers will be interpreted relative to the application process.",type:"string",doc:"Any relative paths used to reference files will be understood as relative to this directory path if the map is loaded from an in memory object rather than from the filesystem. If the map is loaded from the filesystem and this option is not provided it will be set to the directory of the stylesheet."},"paths-from-xml":{css:"","default-value":!0,"default-meaning":"Paths read from XML will be interpreted from the location of the XML",type:"boolean",doc:"value to control whether paths in the XML will be interpreted from the location of the XML or from the working directory of the program that calls load_map()"},"minimum-version":{css:"","default-value":"none","default-meaning":"Mapnik version will not be detected and no error will be thrown about compatibility",type:"string",doc:"The minumum Mapnik version (e.g. 0.7.2) needed to use certain functionality in the stylesheet"},"font-directory":{css:"font-directory",type:"uri","default-value":"none","default-meaning":"No map-specific fonts will be registered",doc:"Path to a directory which holds fonts which should be registered when the Map is loaded (in addition to any fonts that may be automatically registered)."}},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"},gamma:{css:"polygon-gamma",type:"float","default-value":1,"default-meaning":"fully antialiased",range:"0-1",doc:"Level of antialiasing of polygon edges"},"gamma-method":{css:"polygon-gamma-method",type:["power","linear","none","threshold","multiply"],"default-value":"power","default-meaning":"pow(x,gamma) is used to calculate pixel gamma, which produces slightly smoother line and polygon antialiasing than the 'linear' method, while other methods are usually only used to disable AA",doc:"An Antigrain Geometry specific rendering hint to control the quality of antialiasing. Under the hood in Mapnik this method is used in combination with the 'gamma' value (which defaults to 1). The methods are in the AGG source at https://github.com/mapnik/mapnik/blob/master/deps/agg/include/agg_gamma_functions.h"},clip:{css:"polygon-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},smooth:{css:"polygon-smooth",type:"float","default-value":0,"default-meaning":"no smoothing",range:"0-1",doc:"Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries."},"geometry-transform":{css:"polygon-geometry-transform",type:"functions","default-value":"none","default-meaning":"geometry will not be transformed",doc:"Allows transformation functions to be applied to the geometry.",functions:[["matrix",6],["translate",2],["scale",2],["rotate",3],["skewX",1],["skewY",1]]},"comp-op":{css:"polygon-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"]}},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"},"stroke-gamma":{css:"line-gamma",type:"float","default-value":1,"default-meaning":"fully antialiased",range:"0-1",doc:"Level of antialiasing of stroke line"},"stroke-gamma-method":{css:"line-gamma-method",type:["power","linear","none","threshold","multiply"],"default-value":"power","default-meaning":"pow(x,gamma) is used to calculate pixel gamma, which produces slightly smoother line and polygon antialiasing than the 'linear' method, while other methods are usually only used to disable AA",doc:"An Antigrain Geometry specific rendering hint to control the quality of antialiasing. Under the hood in Mapnik this method is used in combination with the 'gamma' value (which defaults to 1). The methods are in the AGG source at https://github.com/mapnik/mapnik/blob/master/deps/agg/include/agg_gamma_functions.h"},"stroke-dasharray":{css:"line-dasharray",type:"numbers",doc:"A pair of length values [a,b], where (a) is the dash length and (b) is the gap length respectively. More than two values are supported for more complex patterns.","default-value":"none","default-meaning":"solid line"},"stroke-dashoffset":{css:"line-dash-offset",type:"numbers",doc:"valid parameter but not currently used in renderers (only exists for experimental svg support in Mapnik which is not yet enabled)","default-value":"none","default-meaning":"solid line"},"stroke-miterlimit":{css:"line-miterlimit",type:"float",doc:"The limit on the ratio of the miter length to the stroke-width. Used to automatically convert miter joins to bevel joins for sharp angles to avoid the miter extending beyond the thickness of the stroking path. Normally will not need to be set, but a larger value can sometimes help avoid jaggy artifacts.","default-value":4,"default-meaning":"Will auto-convert miters to bevel line joins when theta is less than 29 degrees as per the SVG spec: 'miterLength / stroke-width = 1 / sin ( theta / 2 )'"},clip:{css:"line-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},smooth:{css:"line-smooth",type:"float","default-value":0,"default-meaning":"no smoothing",range:"0-1",doc:"Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries."},offset:{css:"line-offset",type:"float","default-value":0,"default-meaning":"no offset",doc:"Offsets a line a number of pixels parallel to its actual path. Postive values move the line left, negative values move it right (relative to the directionality of the line)."},rasterizer:{css:"line-rasterizer",type:["full","fast"],"default-value":"full",doc:"Exposes an alternate AGG rendering method that sacrifices some accuracy for speed."},"geometry-transform":{css:"line-geometry-transform",type:"functions","default-value":"none","default-meaning":"geometry will not be transformed",doc:"Allows transformation functions to be applied to the geometry.",functions:[["matrix",6],["translate",2],["scale",2],["rotate",3],["skewX",1],["skewY",1]]},"comp-op":{css:"line-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"]}},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"},placement:{css:"marker-placement",type:["point","line","interior"],"default-value":"point","default-meaning":"Place markers at the center point (centroid) of the geometry",doc:"Attempt to place markers on a point, in the center of a polygon, or if markers-placement:line, then multiple times along a line. 'interior' placement can be used to ensure that points placed on polygons are forced to be inside the polygon interior"},"multi-policy":{css:"marker-multi-policy",type:["each","whole","largest"],"default-value":"each","default-meaning":"If a feature contains multiple geometries and the placement type is either point or interior then a marker will be rendered for each",doc:"A special setting to allow the user to control rendering behavior for 'multi-geometries' (when a feature contains multiple geometries). This setting does not apply to markers placed along lines. The 'each' policy is default and means all geometries will get a marker. The 'whole' policy means that the aggregate centroid between all geometries will be used. The 'largest' policy means that only the largest (by bounding box areas) feature will get a rendered marker (this is how text labeling behaves by default)."},"marker-type":{css:"marker-type",type:["arrow","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 arrow 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:"expression"},height:{css:"marker-height","default-value":10,doc:"The height of the marker, if using one of the default types.",type:"expression"},fill:{css:"marker-fill","default-value":"blue",doc:"The color of the area of the marker.",type:"color"},"allow-overlap":{css:"marker-allow-overlap",type:"boolean","default-value":!1,doc:"Control whether overlapping markers are shown or hidden.","default-meaning":"Do not allow makers to overlap with each other - overlapping markers will not be shown."},"ignore-placement":{css:"marker-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"},spacing:{css:"marker-spacing",doc:"Space between repeated labels","default-value":100,type:"float"},"max-error":{css:"marker-max-error",type:"float","default-value":.2,doc:"The maximum difference between actual marker placement and the marker-spacing parameter. Setting a high value can allow the renderer to try to resolve placement conflicts with other symbolizers."},transform:{css:"marker-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"},clip:{css:"marker-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},smooth:{css:"marker-smooth",type:"float","default-value":0,"default-meaning":"no smoothing",range:"0-1",doc:"Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries."},"geometry-transform":{css:"marker-geometry-transform",type:"functions","default-value":"none","default-meaning":"geometry will not be transformed",doc:"Allows transformation functions to be applied to the geometry.",functions:[["matrix",6],["translate",2],["scale",2],["rotate",3],["skewX",1],["skewY",1]]},"comp-op":{css:"marker-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"]}},shield:{name:{css:"shield-name",type:"expression",serialization:"content",doc:'Value to use for a shield"s text label. Data columns are specified using brackets like [column_name]'},file:{css:"shield-file",required:!0,type:"uri","default-value":"none",doc:"Image file to render behind the shield text"},"face-name":{css:"shield-face-name",type:"string",validate:"font",doc:"Font name and style to use for the shield text","default-value":"",required:!0},"unlock-image":{css:"shield-unlock-image",type:"boolean",doc:"This parameter should be set to true if you are trying to position text beside rather than on top of the shield image","default-value":!1,"default-meaning":"text alignment relative to the shield image uses the center of the image as the anchor for text positioning."},size:{css:"shield-size",type:"float",doc:"The size of the shield text in pixels"},fill:{css:"shield-fill",type:"color",doc:"The color of the shield text"},placement:{css:"shield-placement",type:["point","line","vertex","interior"],"default-value":"point",doc:"How this shield should be placed. Point placement attempts to place it on top of points, line places along lines multiple times per feature, vertex places on the vertexes of polygons, and interior attempts to place inside of polygons."},"avoid-edges":{css:"shield-avoid-edges",doc:"Tell positioning algorithm to avoid labeling near intersection edges.",type:"boolean","default-value":!1},"allow-overlap":{css:"shield-allow-overlap",type:"boolean","default-value":!1,doc:"Control whether overlapping shields are shown or hidden.","default-meaning":"Do not allow shields to overlap with other map elements already placed."},"minimum-distance":{css:"shield-min-distance",type:"float","default-value":0,doc:"Minimum distance to the next shield symbol, not necessarily the same shield."},spacing:{css:"shield-spacing",type:"float","default-value":0,doc:"The spacing between repeated occurrences of the same shield on a line"},"minimum-padding":{css:"shield-min-padding","default-value":0,doc:"Determines the minimum amount of padding that a shield gets relative to other shields",type:"float"},"wrap-width":{css:"shield-wrap-width",type:"unsigned","default-value":0,doc:"Length of a chunk of text in characters before wrapping text"},"wrap-before":{css:"shield-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:"shield-wrap-character",type:"string","default-value":" ",doc:"Use this character instead of a space to wrap long names."},"halo-fill":{css:"shield-halo-fill",type:"color","default-value":"#FFFFFF","default-meaning":"white",doc:"Specifies the color of the halo around the text."},"halo-radius":{css:"shield-halo-radius",doc:"Specify the radius of the halo in pixels","default-value":0,"default-meaning":"no halo",type:"float"},"character-spacing":{css:"shield-character-spacing",type:"unsigned","default-value":0,doc:"Horizontal spacing between characters (in pixels). Currently works for point placement only, not line placement."},"line-spacing":{css:"shield-line-spacing",doc:"Vertical spacing between lines of multiline labels (in pixels)",type:"unsigned"},dx:{css:"shield-text-dx",type:"float",doc:"Displace text within shield by fixed amount, in pixels, +/- along the X axis. A positive value will shift the text right","default-value":0},dy:{css:"shield-text-dy",type:"float",doc:"Displace text within shield by fixed amount, in pixels, +/- along the Y axis. A positive value will shift the text down","default-value":0},"shield-dx":{css:"shield-dx",type:"float",doc:"Displace shield by fixed amount, in pixels, +/- along the X axis. A positive value will shift the text right","default-value":0},"shield-dy":{css:"shield-dy",type:"float",doc:"Displace shield by fixed amount, in pixels, +/- along the Y axis. A positive value will shift the text down","default-value":0},opacity:{css:"shield-opacity",type:"float",doc:"(Default 1.0) - opacity of the image used for the shield","default-value":1},"text-opacity":{css:"shield-text-opacity",type:"float",doc:"(Default 1.0) - opacity of the text placed on top of the shield","default-value":1},"horizontal-alignment":{css:"shield-horizontal-alignment",type:["left","middle","right","auto"],doc:"The shield's horizontal alignment from its centerpoint","default-value":"auto"},"vertical-alignment":{css:"shield-vertical-alignment",type:["top","middle","bottom","auto"],doc:"The shield's vertical alignment from its centerpoint","default-value":"middle"},"text-transform":{css:"shield-text-transform",type:["none","uppercase","lowercase","capitalize"],doc:"Transform the case of the characters","default-value":"none"},"justify-alignment":{css:"shield-justify-alignment",type:["left","center","right","auto"],doc:"Define how text in a shield's label is justified","default-value":"auto"},clip:{css:"shield-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},"comp-op":{css:"shield-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"]}},"line-pattern":{file:{css:"line-pattern-file",type:"uri","default-value":"none",required:!0,doc:"An image file to be repeated and warped along a line"},clip:{css:"line-pattern-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},smooth:{css:"line-pattern-smooth",type:"float","default-value":0,"default-meaning":"no smoothing",range:"0-1",doc:"Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries."},"geometry-transform":{css:"line-pattern-geometry-transform",type:"functions","default-value":"none","default-meaning":"geometry will not be transformed",doc:"Allows transformation functions to be applied to the geometry.",functions:[["matrix",6],["translate",2],["scale",2],["rotate",3],["skewX",1],["skewY",1]]},"comp-op":{css:"line-pattern-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"]}},"polygon-pattern":{file:{css:"polygon-pattern-file",type:"uri","default-value":"none",required:!0,doc:"Image to use as a repeated pattern fill within a polygon"},alignment:{css:"polygon-pattern-alignment",type:["local","global"],"default-value":"local",doc:"Specify whether to align pattern fills to the layer or to the map."},gamma:{css:"polygon-pattern-gamma",type:"float","default-value":1,"default-meaning":"fully antialiased",range:"0-1",doc:"Level of antialiasing of polygon pattern edges"},opacity:{css:"polygon-pattern-opacity",type:"float",doc:"(Default 1.0) - Apply an opacity level to the image used for the pattern","default-value":1,"default-meaning":"The image is rendered without modifications"},clip:{css:"polygon-pattern-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},smooth:{css:"polygon-pattern-smooth",type:"float","default-value":0,"default-meaning":"no smoothing",range:"0-1",doc:"Smooths out geometry angles. 0 is no smoothing, 1 is fully smoothed. Values greater than 1 will produce wild, looping geometries."},"geometry-transform":{css:"polygon-pattern-geometry-transform",type:"functions","default-value":"none","default-meaning":"geometry will not be transformed",doc:"Allows transformation functions to be applied to the geometry.",functions:[["matrix",6],["translate",2],["scale",2],["rotate",3],["skewX",1],["skewY",1]]},"comp-op":{css:"polygon-pattern-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"]}},raster:{opacity:{css:"raster-opacity","default-value":1,"default-meaning":"opaque",type:"float",doc:"The opacity of the raster symbolizer on top of other symbolizers."},"filter-factor":{css:"raster-filter-factor","default-value":-1,"default-meaning":"Allow the datasource to choose appropriate downscaling.",type:"float",doc:"This is used by the Raster or Gdal datasources to pre-downscale images using overviews. Higher numbers can sometimes cause much better scaled image output, at the cost of speed."},scaling:{css:"raster-scaling",type:["near","fast","bilinear","bilinear8","bicubic","spline16","spline36","hanning","hamming","hermite","kaiser","quadric","catrom","gaussian","bessel","mitchell","sinc","lanczos","blackman"],"default-value":"near",doc:"The scaling algorithm used to making different resolution versions of this raster layer. Bilinear is a good compromise between speed and accuracy, while lanczos gives the highest quality."
|
|
},"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-spacing":{css:"text-character-spacing",type:"float","default-value":0,doc:"Horizontal spacing adjustment between characters in pixels"},"line-spacing":{css:"text-line-spacing","default-value":0,type:"unsigned",doc:"Vertical spacing adjustment between lines in pixels"},"label-position-tolerance":{css:"text-label-position-tolerance","default-value":0,type:"unsigned",doc:"Allows the label to be displaced from its ideal position by a number of pixels (only works with placement:line)"},"max-char-angle-delta":{css:"text-max-char-angle-delta",type:"float","default-value":"22.5",doc:"The maximum angle change, in degrees, allowed between adjacent characters in a label. This value internally is converted to radians to the default is 22.5*math.pi/180.0. The higher the value the fewer labels will be placed around around sharp corners."},fill:{css:"text-fill",doc:"Specifies the color for the text","default-value":"#000000",type:"color"},opacity:{css:"text-opacity",doc:"A number from 0 to 1 specifying the opacity for the text","default-value":1,"default-meaning":"Fully opaque",type:"float"},"halo-fill":{css:"text-halo-fill",type:"color","default-value":"#FFFFFF","default-meaning":"white",doc:"Specifies the color of the halo around the text."},"halo-radius":{css:"text-halo-radius",doc:"Specify the radius of the halo in pixels","default-value":0,"default-meaning":"no halo",type:"float"},dx:{css:"text-dx",type:"float",doc:"Displace text by fixed amount, in pixels, +/- along the X axis. A positive value will shift the text right","default-value":0},dy:{css:"text-dy",type:"float",doc:"Displace text by fixed amount, in pixels, +/- along the Y axis. A positive value will shift the text down","default-value":0},"vertical-alignment":{css:"text-vertical-alignment",type:["top","middle","bottom","auto"],doc:"Position of label relative to point position.","default-value":"auto","default-meaning":'Default affected by value of dy; "bottom" for dy>0, "top" for dy<0.'},"avoid-edges":{css:"text-avoid-edges",doc:"Tell positioning algorithm to avoid labeling near intersection edges.","default-value":!1,type:"boolean"},"minimum-distance":{css:"text-min-distance",doc:"Minimum permitted distance to the next text symbolizer.",type:"float"},"minimum-padding":{css:"text-min-padding",doc:"Determines the minimum amount of padding that a text symbolizer gets relative to other text",type:"float"},"minimum-path-length":{css:"text-min-path-length",type:"float","default-value":0,"default-meaning":"place labels on all paths",doc:"Place labels only on paths longer than this value."},"allow-overlap":{css:"text-allow-overlap",type:"boolean","default-value":!1,doc:"Control whether overlapping text is shown or hidden.","default-meaning":"Do not allow text to overlap with other text - overlapping markers will not be shown."},orientation:{css:"text-orientation",type:"expression",doc:"Rotate the text."},placement:{css:"text-placement",type:["point","line","vertex","interior"],"default-value":"point",doc:"Control the style of placement of a point versus the geometry it is attached to."},"placement-type":{css:"text-placement-type",doc:'Re-position and/or re-size text to avoid overlaps. "simple" for basic algorithm (using text-placements string,) "dummy" to turn this feature off.',type:["dummy","simple"],"default-value":"dummy"},placements:{css:"text-placements",type:"string","default-value":"",doc:'If "placement-type" is set to "simple", use this "POSITIONS,[SIZES]" string. An example is `text-placements: "E,NE,SE,W,NW,SW";` '},"text-transform":{css:"text-transform",type:["none","uppercase","lowercase","capitalize"],doc:"Transform the case of the characters","default-value":"none"},"horizontal-alignment":{css:"text-horizontal-alignment",type:["left","middle","right","auto"],doc:"The text's horizontal alignment from its centerpoint","default-value":"auto"},"justify-alignment":{css:"text-align",type:["left","right","center","auto"],doc:"Define how text is justified","default-value":"auto","default-meaning":"Auto alignment means that text will be centered by default except when using the `placement-type` parameter - in that case either right or left justification will be used automatically depending on where the text could be fit given the `text-placements` directives"},clip:{css:"text-clip",type:"boolean","default-value":!0,"default-meaning":"geometry will be clipped to map bounds before rendering",doc:"geometries are clipped to map bounds by default for best rendering performance. In some cases users may wish to disable this to avoid rendering artifacts."},"comp-op":{css:"text-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"]}},building:{fill:{css:"building-fill","default-value":"#FFFFFF",doc:"The color of the buildings walls.",type:"color"},"fill-opacity":{css:"building-fill-opacity",type:"float",doc:"The opacity of the building as a whole, including all walls.","default-value":1},height:{css:"building-height",doc:"The height of the building in pixels.",type:"expression","default-value":"0"}}},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]},filter:{value:["true","false","null","point","linestring","polygon","collection"]}};window.carto["mapnik-reference"]={version:{latest:_mapnik_reference_latest,"2.1.1":_mapnik_reference_latest}},window.carto=window.carto||{},window.carto.underscore=window._,typeof exports!="undefined"?(carto=exports,tree=require("./tree"),_=require("underscore")):(typeof window.carto=="undefined"&&(window.carto={}),carto=window.carto,tree=window.carto.tree={},_=window._),carto.Parser=function(t){function d(){s=a[i],o=r,f=r}function v(){a[i]=s,r=o,f=r}function m(){r>f&&(a[i]=a[i].slice(r-f),f=r)}function g(e){var t,s,o,u,c,h,p;if(e instanceof Function)return e.call(l.parsers);if(typeof e=="string")t=n.charAt(r)===e?e:null,o=1,m();else{m(),t=e.exec(a[i]);if(!t)return null;o=t[0].length}if(t){var d=r+=o;h=r+a[i].length-o;while(r<h){u=n.charCodeAt(r);if(u!==32&&u!==10&&u!==9)break;r++}return a[i]=a[i].slice(o+(r-d)),f=r,a[i].length===0&&i<a.length-1&&i++,typeof t=="string"?t:t.length===1?t[0]:t}}function y(e){return typeof e=="string"?n.charAt(r)===e:e.test(a[i])?!0:!1}function b(e,t){return(e.slice(0,t).match(/\n/g)||"").length+1}function w(e){var r;_(e).defaults({index:u,filename:t.filename,message:"Parse error.",line:0,column:-1}),e.filename&&c.env.inputs&&c.env.inputs[e.filename]?r=c.env.inputs[e.filename]:r=n,e.line=b(r,e.index);for(var i=e.index;i>=0&&r.charAt(i)!=="\n";i--)e.column++;return new Error(_("<%=filename%>:<%=line%>:<%=column%> <%=message%>").template(e))}var n,r,i,s,o,u,a,f,l,c=this,h=function(){},p=this.imports={paths:t&&t.paths||[],queue:[],files:{},mime:t&&t.mime,push:function(e,n){var r=this;this.queue.push(e),carto.Parser.importer(e,this.paths,function(t){r.queue.splice(r.queue.indexOf(e),1),r.files[e]=t,n(t),r.queue.length===0&&h()},t)}};return this.env=t=t||{},this.env.filename=this.env.filename||null,this.env.inputs=this.env.inputs||{},l={imports:p,extractErrorLine:b,parse:function(e){var s,o,l,h,p,d,v=[],m,y=null;r=i=f=u=0,a=[],n=e.replace(/\r\n/g,"\n"),t.filename&&(c.env.inputs[t.filename]=n);var b=!1;a=function(e){var t=0,r=/[^"'`\{\}\/]+/g,i=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,s=0,o,u=e[0],a;e:for(var f=0,l,c;f<n.length;f++){r.lastIndex=f,(o=r.exec(n))&&o.index===f&&(f+=o[0].length,u.push(o[0])),l=n.charAt(f),i.lastIndex=f;if(!a&&l==="/"){c=n.charAt(f+1);if(c==="/"||c==="*")if(o=i.exec(n))if(o.index===f){f+=o[0].length-1,u.push(o[0]),l=n.charAt(f);continue e}}if(l==="{"&&!a)s++,u.push(l);else if(l==="}"&&!a)s--,u.push(l),e[++t]=u=[];else{if(l==='"'||l==="'"||l==="`")a?a=a===l?!1:a:a=l;u.push(l)}}if(s>0)throw w({message:"Missing closing `}`",index:f});return e.map(function(e){return e.join("")})}([[]]),s=new tree.Ruleset([],g(this.parsers.primary)),s.root=!0,s.toList=function(){var e,t,n;return function(e){e.error=function(t){e.errors||(e.errors=new Error("")),e.errors.message?e.errors.message+="\n"+w(t).message:e.errors.message=w(t).message},e.frames=e.frames||[];var t=this.flatten([],[],e);return t.sort(E),t}}();var E=function(e,t){var n=e.specificity,r=t.specificity;return n[0]!=r[0]?r[0]-n[0]:n[1]!=r[1]?r[1]-n[1]:n[2]!=r[2]?r[2]-n[2]:r[3]-n[3]};if(r<n.length-1)throw w({message:"Parse error.",index:r});return s},parsers:{primary:function(){var e,t=[];while((e=g(this.rule)||g(this.ruleset)||g(this.comment))||g(/^[\s\n]+/)||(e=g(this.invalid)))e&&t.push(e);return t},invalid:function(){var e=g(/^[^;\n]*[;\n]/);if(e)return new tree.Invalid(e,o)},comment:function(){var e;if(n.charAt(r)!=="/")return;if(n.charAt(r+1)==="/")return new tree.Comment(g(/^\/\/.*/),!0);if(e=g(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new tree.Comment(e)},entities:{quoted:function(){if(n.charAt(r)!=='"'&&n.charAt(r)!=="'")return;var e=g(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/);if(e)return new tree.Quoted(e[1]||e[2])},field:function(){if(!g("["))return;var e=g(/(^[a-zA-Z0-9\-_]+)/);if(!g("]"))return;if(e)return new tree.Field(e[1])},comparison:function(){var e=g(/^=~|=|!=|<=|>=|<|>/);if(e)return e},keyword:function(){var e=g(/^[A-Za-z-]+[A-Za-z-0-9_]*/);if(e)return new tree.Keyword(e)},call:function(){var e,t;if(!(e=/^([\w\-]+|%)\(/.exec(a[i])))return;e=e[1].toLowerCase();if(e==="url")return null;r+=e.length+1,t=g(this.entities.arguments);if(!g(")"))return;if(e)return new tree.Call(e,t,r)},arguments:function(){var e=[],t;while(t=g(this.expression)){e.push(t);if(!g(","))break}return e},literal:function(){return g(this.entities.dimension)||g(this.entities.color)||g(this.entities.quoted)},url:function(){var e;if(n.charAt(r)!=="u"||!g(/^url\(/))return;return e=g(this.entities.quoted)||g(this.entities.variable)||g(/^[\-\w%@$\/.&=:;#+?~]+/)||"",g(")")?new tree.URL(e.value||e instanceof tree.Variable?e:new tree.Quoted(e),p.paths):new tree.Invalid(e,o,"Missing closing ) in URL.")},variable:function(){var e,i=r;if(n.charAt(r)==="@"&&(e=g(/^@[\w-]+/)))return new tree.Variable(e,i,t.filename)},color:function(){var e;if(n.charAt(r)==="#"&&(e=g(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new tree.Color(e[1]);e=a[i].match(/^[a-z]+/);if(e&&e[0]in tree.Reference.data.colors)return new tree.Color(tree.Reference.data.colors[g(/^[a-z]+/)])},dimension:function(){var e=n.charCodeAt(r);if(e>57||e<45||e===47)return;var t=g(/^(-?\d*\.?\d+)(\%|\w+)?/);if(t)return new tree.Dimension(t[1],t[2],o)}},variable:function(){var e;if(n.charAt(r)==="@"&&(e=g(/^(@[\w-]+)\s*:/)))return e[1]},entity:function(){return g(this.entities.literal)||g(this.entities.field)||g(this.entities.variable)||g(this.entities.url)||g(this.entities.call)||g(this.entities.keyword)},end:function(){return g(";")||y("}")},element:function(){var e=g(/^(?:[.#][\w\-]+|\*|Map)/);if(e)return new tree.Element(e)},attachment:function(){var e=g(/^::([\w\-]+(?:\/[\w\-]+)*)/);if(e)return e[1]},selector:function(){var e,t,i,s=[],u,a=new tree.Filterset,f,l=tree.Zoom.all,c,h=tree.FrameOffset.none,p=0,d=0;while((i=g(this.element))||(f=g(this.zoom))||(c=g(this.frame_offset))||(u=g(this.filter))||(e=g(this.attachment))){p++;if(i)s.push(i);else if(f)l&=f,d++;else if(c)h=c,d++;else if(u)a.add(u),d++;else{if(t)throw w({message:"Encountered second attachment name.",index:r-1});t=e}var v=n.charAt(r);if(v==="{"||v==="}"||v===";"||v===",")break}if(p)return new tree.Selector(a,l,h,s,t,d,o)},filter:function(){d();var e,n,r;if(!g("["))return;if(e=g(/^[a-zA-Z0-9\-_]+/)||g(this.entities.quoted)||g(this.entities.variable))if((n=g(this.entities.comparison))&&(r=g(this.entities.quoted)||g(this.entities.variable)||g(/^[\w\-\.]+/))){if(!g("]"))return;return new tree.Filter(e,n,r,o,t.filename)}},frame_offset:function(){d();var e,t;if(g(/^\[\s*frame-offset/g)&&(e=g(this.entities.comparison))&&(t=g(/^\d+/))&&g("]"))return tree.FrameOffset(e,t,o)},zoom:function(){d();var e,t;if(g(/^\[\s*zoom/g)&&(e=g(this.entities.comparison))&&(t=g(/^\d+/))&&g("]"))return tree.Zoom(e,t,o)},block:function(){var e;if(g("{")&&(e=g(this.primary))&&g("}"))return e},ruleset:function(){var e=[],t,n,r,i,s=[];d();while(t=g(this.selector)){e.push(t);if(!g(","))break}t&&g(this.comment);if(e.length>0&&(i=g(this.block))){if(e.length===1&&e[0].elements.length&&e[0].elements[0].value==="Map"){var o=new tree.Ruleset(e,i);return o.isMap=!0,o}return new tree.Ruleset(e,i)}v()},rule:function(){var e,i,s=n.charAt(r);d();if(s==="."||s==="#"||s==="&")return;if(e=g(this.variable)||g(this.property)){i=g(this.value);if(i&&g(this.end))return new tree.Rule(e,i,o,t.filename);u=r,v()}},font:function(){var e=[],t=[],n,r,i;while(i=g(this.entity))t.push(i);e.push(new tree.Expression(t));if(g(","))while(i=g(this.expression)){e.push(i);if(!g(","))break}return new tree.Value(e)},value:function(){var e,t=[];while(e=g(this.expression)){t.push(e);if(!g(","))break}if(t.length>0)return new tree.Value(t)},sub:function(){var e;if(g("(")&&(e=g(this.expression))&&g(")"))return e},multiplication:function(){var e,t,n,r;if(e=g(this.operand)){while((n=g("/")||g("*")||g("%"))&&(t=g(this.operand)))r=new tree.Operation(n,[r||e,t],o);return r||e}},addition:function(){var e,t,i,s;if(e=g(this.multiplication)){while((i=g(/^[-+]\s+/)||n.charAt(r-1)!=" "&&(g("+")||g("-")))&&(t=g(this.multiplication)))s=new tree.Operation(i,[s||e,t],o);return s||e}},operand:function(){return g(this.sub)||g(this.entity)},expression:function(){var e,t,n=[],r;while(e=g(this.addition)||g(this.entity))n.push(e);if(n.length>0)return new tree.Expression(n)},property:function(){var e=g(/^(([a-z][-a-z_0-9]*\/)?\*?-?[-a-z_0-9]+)\s*:/);if(e)return e[1]}}}},typeof module!="undefined"&&(module.exports.find=function(e,t){for(var n=0,r;n<e.length;n++)if(r=t.call(e,e[n]))return r;return null}),function(e){e.Anonymous=function(t){this.value=t.value||t},e.Anonymous.prototype={toString:function(){return this.value},eval:function(){return this}}}(require("../tree")),function(e){e.Call=function(t,n,r){this.is="call",this.name=t,this.args=n,this.index=r},e.Call.prototype={eval:function(t){var n=this.args.map(function(e){return e.eval(t)});for(var r=0;r<n.length;r++)if(n[r].is==="undefined")return{is:"undefined",value:"undefined"};if(this.name in e.functions)return e.functions[this.name].length===n.length?e.functions[this.name].apply(e.functions,n):(t.error({message:"incorrect number of arguments for "+this.name+"(). "+e.functions[this.name].length+" expected.",index:this.index,type:"runtime",filename:this.filename}),{is:"undefined",value:"undefined"});var i=e.Reference.mapnikFunction(this.name);return i?i[1]!==n.length?(t.error({message:"function "+this.name+" takes "+i[1]+" arguments and was given "+n.length,index:this.index,type:"runtime",filename:this.filename}),{is:"undefined",value:"undefined"}):(this.args=n,this):(t.error({message:"unknown function "+this.name,index:this.index,type:"runtime",filename:this.filename}),{is:"undefined",value:"undefined"})},toString:function(e,t){return t==="image-filter"?this.args.length?this.name+":"+this.args.join(","):this.name:this.args.length?this.name+"("+this.args.join(",")+")":this.name}}}(require("../tree")),function(e){e.Color=function(t,n){Array.isArray(t)?this.rgb=t:t.length==6?this.rgb=t.match(/.{2}/g).map(function(e){return parseInt(e,16)}):this.rgb=t.split("").map(function(e){return parseInt(e+e,16)}),this.is="color",this.alpha=typeof n=="number"?n:1},e.Color.prototype={eval:function(){return this},toString:function(){return this.alpha<1?"rgba("+this.rgb.map(function(e){return Math.round(e)}).concat(this.alpha).join(", ")+")":"#"+this.rgb.map(function(e){return e=Math.round(e),e=(e>255?255:e<0?0:e).toString(16),e.length===1?"0"+e:e}).join("")},operate:function(t,n){var r=[];n instanceof e.Color||(n=n.toColor());for(var i=0;i<3;i++)r[i]=e.operate(t,this.rgb[i],n.rgb[i]);return new e.Color(r)},toHSL:function(){var e=this.rgb[0]/255,t=this.rgb[1]/255,n=this.rgb[2]/255,r=this.alpha,i=Math.max(e,t,n),s=Math.min(e,t,n),o,u,a=(i+s)/2,f=i-s;if(i===s)o=u=0;else{u=a>.5?f/(2-i-s):f/(i+s);switch(i){case e:o=(t-n)/f+(t<n?6:0);break;case t:o=(n-e)/f+2;break;case n:o=(e-t)/f+4}o/=6}return{h:o*360,s:u,l:a,a:r}}}}(require("../tree")),function(e){e.Comment=function(t,n){this.value=t,this.silent=!!n},e.Comment.prototype={toString:function(e){return"<!--"+this.value+"-->"},eval:function(){return this}}}(require("../tree")),function(e){var t=require("assert");e.Definition=function(r,i){this.elements=r.elements,t.ok(r.filters instanceof e.Filterset),this.rules=i,this.ruleIndex=[];for(var s=0;s<this.rules.length;s++)"zoom"in this.rules[s]&&(this.rules[s]=this.rules[s].clone()),this.rules[s].zoom=r.zoom,this.ruleIndex.push(this.rules[s].updateID());this.filters=r.filters,this.zoom=r.zoom,this.frame_offset=r.frame_offset,this.attachment=r.attachment||"__default__",this.specificity=r.specificity()},e.Definition.prototype.toString=function(){var e=this.filters.toString();for(var t=0;t<this.rules.length;t++)e+="\n "+this.rules[t];return e},e.Definition.prototype.clone=function(n){n&&t.ok(n instanceof e.Filterset);var r=Object.create(e.Definition.prototype);return r.rules=this.rules.slice(),r.ruleIndex=this.ruleIndex.slice(),r.filters=n?n:this.filters.clone(),r.attachment=this.attachment,r},e.Definition.prototype.addRules=function(e){var t=0;for(var n=0;n<e.length;n++)this.ruleIndex.indexOf(e[n].id)<0&&(this.rules.push(e[n]),this.ruleIndex.push(e[n].id),t++);return t},e.Definition.prototype.appliesTo=function(e,t){for(var n=0;n<this.elements.length;n++)if(!this.elements[n].matches(e,t))return!1;return!0},e.Definition.prototype.symbolizersToXML=function(t,n,r){var i=" <Rule>\n";i+=e.Zoom.toXML(r).join(""),i+=this.filters.toXML(t);var s=[],o=[];for(var u in n){o=[];for(var a in n[u])o.push(n[u][a].index);var f=Math.min.apply(Math,o);s.push([u,f])}s=s.sort(function(e,t){return e[1]-t[1]}).map(function(e){return e[0]});for(var l=0;l<s.length;l++){var c=n[s[l]],h=s[l].split("/").pop();if(h==="*")continue;var p=e.Reference.requiredProperties(h,c);if(p){var d=c[Object.keys(c).shift()];t.error({message:p,index:d.index,filename:d.filename})}var v=h.charAt(0).toUpperCase()+h.slice(1).replace(/\-./,function(e){return e[1].toUpperCase()})+"Symbolizer",m=!0,g;i+=" <"+v+" ";for(var u in c){h==="map"&&t.error({message:"Map properties are not permitted in other rules",index:c[u].index,filename:c[u].filename});var y=e.Reference.selector(c[u].name);y&&y.serialization&&y.serialization==="content"?(m=!1,g=c[u].eval(t).toXML(t,!0)):i+=c[u].eval(t).toXML(t)+" "}m?i+="/>\n":i+="><![CDATA["+g+"]]></"+v+">\n"}return i+=" </Rule>\n",i},e.Definition.prototype.collectSymbolizers=function(e,t){var n={},r;for(var i=t;i<this.rules.length;i++){r=this.rules[i];var s=r.instance+"/"+r.symbolizer;e.current&r.zoom&&(!(s in n)||!(r.name in n[s]))&&(e.current&=r.zoom,s in n||(n[s]={}),n[s][r.name]=r)}if(Object.keys(n).length)return e.rule&=e.available&=~e.current,n},e.Definition.prototype.toXML=function(t,n){var r=this.filters.toString();r in n||(n[r]=e.Zoom.all);var i=e.Zoom.all,s="",o,u,a={available:e.Zoom.all};for(var f=0;f<this.rules.length&&i;f++){a.rule=this.rules[f].zoom;if(!(n[r]&a.rule))continue;while(a.current=a.rule&i)if(u=this.collectSymbolizers(a,f)){if(!(n[r]&a.current))continue;s+=this.symbolizersToXML(t,u,n[r]&a.current),n[r]&=~a.current}}return s}}(require("../tree")),function(e){e.Dimension=function(t,n,r){this.value=parseFloat(t),this.unit=n||null,this.is="float",this.index=r},e.Dimension.prototype={eval:function(e){return this.unit&&["px","%"].indexOf(this.unit)===-1&&e.error({message:"Invalid unit: '"+this.unit+"'",index:this.index}),this},toColor:function(){return new e.Color([this.value,this.value,this.value])},toString:function(){return this.value.toString()},operate:function(t,n){return new e.Dimension(e.operate(t,this.value,n.value),this.unit||n.unit)}}}(require("../tree")),function(e){e.Directive=function(n,r){this.name=n,Array.isArray(r)?this.ruleset=new e.Ruleset([],r):this.value=r},e.Directive.prototype={toString:function(e,t){return this.ruleset?(this.ruleset.root=!0,this.name+" {\n "+this.ruleset.toString(e,t).trim().replace(/\n/g,"\n ")+"\n}\n"):this.name+" "+this.value.toString()+";\n"},eval:function(e){return e.frames.unshift(this),this.ruleset=this.ruleset&&this.ruleset.eval(e),e.frames.shift(),this},variable:function(t){return e.Ruleset.prototype.variable.call(this.ruleset,t)},find:function(){return e.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return e.Ruleset.prototype.rulesets.apply(this.ruleset)}}}(require("../tree")),function(e){e.Element=function(t){this.value=t.trim()},e.Element.prototype.specificity=function(){return[this.value[0]=="#"?1:0,this.value[0]=="."?1:0]},e.Element.prototype.toString=function(){return this.value},e.Element.prototype.matches=function(e,t){return t.indexOf(this.value.replace(/^\./,""))!==-1||this.value.replace(/^#/,"")===e||this.value==="*"}}(require("../tree")),function(e){e.Expression=function(t){this.value=t},e.Expression.prototype={eval:function(t){return this.value.length>1?new e.Expression(this.value.map(function(e){return e.eval(t)})):this.value[0].eval(t)},toString:function(e){return this.value.map(function(t){return t.toString(e)}).join(" ")}}}(require("../tree")),function(e){e.Field=function(t){this.value=t||"",this.is="field"},e.Field.prototype={toString:function(){return"["+this.value+"]"},eval:function(){return this}}}(require("../tree")),function(e){e.Filter=function(n,r,i,s,o){n.is?(this.key=n.value,this._key=n):this.key=n,this.op=r,this.index=s,this.filename=o,i.is?(this.val=i.value,this._val=i):this.val=i,t[this.op][1]=="numeric"&&(this.val=1*this.val),this.id=this.key+this.op+this.val};var t={"<":[" < ","numeric"],">":[" > ","numeric"],"=":[" = ","both"],"!=":[" != ","both"],"<=":[" <= ","numeric"],">=":[" >= ","numeric"],"=~":[".match(","string",")"]};e.Filter.prototype.toXML=function(e){this.val.eval&&(this._val=this.val.eval(e)),this.key.eval&&(this._key=this.key.eval(e));if(this._key)var n=this._key.toString(!1);if(this._val)var r=this._val.toString(this._val.is=="string");return(t[this.op][1]=="numeric"&&isNaN(this.val)||t[this.op][1]=="string"&&(r||this.val)[0]!="'")&&e.error({message:'Cannot use operator "'+this.op+'" with value '+this.val,index:this.index,filename:this.filename}),"["+(n||this.key)+"]"+t[this.op][0]+""+(r||this.val)+(t[this.op][2]||"")},e.Filter.prototype.toString=function(){return"["+this.id+"]"}}(require("../tree"));var tree=require("../tree");tree.Filterset=function(){},Object.defineProperty(tree.Filterset.prototype,"toXML",{enumerable:!1,value:function(e){var t=[];for(var n in this)t.push("("+this[n].toXML(e).trim()+")");return t.length?" <Filter>"+t.join(" and ")+"</Filter>\n":""}}),Object.defineProperty(tree.Filterset.prototype,"toString",{enumerable:!1,value:function(){var e=[];for(var t in this)e.push(this[t].id);return e.sort(),e.join(" ")}}),Object.defineProperty(tree.Filterset.prototype,"clone",{enumerable:!1,value:function(){var e=new tree.Filterset;for(var t in this)e[t]=this[t];return e}}),Object.defineProperty(tree.Filterset.prototype,"cloneWith",{enumerable:!1,value:function(e){var t;for(var n in e){var r=this.addable(e[n]);if(r===!1)return!1;r===!0&&(t||(t=[]),t.push(e[n]))}if(!t)return null;var i=new tree.Filterset;for(var n in this)i[n]=this[n];while(n=t.shift())i.add(n);return i}}),Object.defineProperty(tree.Filterset.prototype,"addable",{enumerable:!1,value:function(e){var t=e.key,n=e.val;switch(e.op){case"=":if(t+"="in this)return this[t+"="].val!=n?!1:null;if(t+"!="+n in this)return!1;if(t+">"in this&&this[t+">"].val>=n)return!1;if(t+"<"in this&&this[t+"<"].val<=n)return!1;if(t+">="in this&&this[t+">="].val>n)return!1;if(t+"<="in this&&this[t+"<="].val<n)return!1;return!0;case"!=":if(t+"="in this)return this[t+"="].val==n?!1:null;if(t+"!="+n in this)return null;if(t+">"in this&&this[t+">"].val>=n)return null;if(t+"<"in this&&this[t+"<"].val<=n)return null;if(t+">="in this&&this[t+">="].val>n)return null;if(t+"<="in this&&this[t+"<="].val<n)return null;return!0;case">":if(t+"="in this)return this[t+"="].val<=n?!1:null;if(t+"<"in this&&this[t+"<"].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;case">=":if(t+"="in this)return this[t+"="].val<n?!1:null;if(t+"<"in this&&this[t+"<"].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;case"<":if(t+"="in this)return this[t+"="].val>=n?!1:null;if(t+">"in this&&this[t+">"].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;case"<=":if(t+"="in this)return this[t+"="].val>n?!1:null;if(t+">"in this&&this[t+">"].
|
|
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 instanceof e.Quoted&&this.op!=="+"?(t.error({message:"Can't subtract, divide, or multiply strings.",index:this.index,type:"runtime",filename:this.filename}),{is:"undefined",value:"undefined"}):n instanceof e.Field||r instanceof e.Field||n instanceof e.Literal||r instanceof e.Literal?n.is==="color"||r.is==="color"?(t.error({message:"Can't subtract, divide, or multiply colors in expressions.",index:this.index,type:"runtime",filename:this.filename}),{is:"undefined",value:"undefined"}):new e.Literal(n.eval(t).toString(!0)+this.op+r.eval(t).toString(!0)):n.operate(this.op,r))},e.operate=function(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"%":return t%n;case"/":return t/n}}}(require("../tree")),function(e){e.Quoted=function(t){this.value=t||"",this.is="string"},e.Quoted.prototype={toString:function(e){var t=this.value.replace(/\'/g,"'");return e===!0?"'"+t+"'":this.value},eval:function(){return this},operate:function(t,n){return new e.Quoted(!0,e.operate(t,this.toString(),n.toString(this.contains_field)))}}}(require("../tree")),function(e){var t=require("underscore"),n=require("mapnik-reference");e.Reference={data:n.version.latest},e.Reference.set=function(t,r){n=t,e.Reference.setVersion(r||"latest")},e.Reference.setVersion=function(t){e.Reference.data=n.version[t]},e.Reference.required_prop_list_cache={},e.Reference.selectors=e.Reference.selectors||function(){var t=[];for(var n in e.Reference.data.symbolizers)for(var r in e.Reference.data.symbolizers[n])e.Reference.data.symbolizers[n][r].hasOwnProperty("css")&&t.push(e.Reference.data.symbolizers[n][r].css);return t}(),e.Reference.validSelector=function(t){return e.Reference.selectors.indexOf(t)!==-1},e.Reference.selectorName=function(t){for(var n in e.Reference.data.symbolizers)for(var r in e.Reference.data.symbolizers[n])if(t==e.Reference.data.symbolizers[n][r].css)return r},e.Reference.selector=function(t){for(var n in e.Reference.data.symbolizers)for(var r in e.Reference.data.symbolizers[n])if(t==e.Reference.data.symbolizers[n][r].css)return e.Reference.data.symbolizers[n][r]},e.Reference.symbolizer=function(t){for(var n in e.Reference.data.symbolizers)for(var r in e.Reference.data.symbolizers[n])if(t==e.Reference.data.symbolizers[n][r].css)return n},e.Reference.mapnikFunction=function(n){var r=[];for(var i in e.Reference.data.symbolizers)for(var s in e.Reference.data.symbolizers[i])e.Reference.data.symbolizers[i][s].type==="functions"&&(r=r.concat(e.Reference.data.symbolizers[i][s].functions));return t.find(r,function(e){return e[0]===n})},e.Reference.requiredPropertyList=function(t){if(this.required_prop_list_cache[t])return this.required_prop_list_cache[t];var n=[];for(var r in e.Reference.data.symbolizers[t])e.Reference.data.symbolizers[t][r].required&&n.push(e.Reference.data.symbolizers[t][r].css);return this.required_prop_list_cache[t]=n},e.Reference.requiredProperties=function(t,n){var r=e.Reference.requiredPropertyList(t);for(var i in r)if(!(r[i]in n))return"Property "+r[i]+" required for defining "+t+" styles."},e.Reference._validateValue={font:function(e,t){return e.validation_data&&e.validation_data.fonts?e.validation_data.fonts.indexOf(t)!=-1:!0}},e.Reference.isFont=function(t){return e.Reference.selector(t).validate=="font"},e.Reference.validValue=function(n,r,i){var s,o;if(!e.Reference.selector(r))return!1;if(i.value[0].is=="keyword")return e.Reference.selector(r).type.indexOf(i.value[0].value)!==-1;if(i.value[0].is=="undefined")return!0;if(e.Reference.selector(r).type=="numbers"){for(s in i.value)if(i.value[s].is!=="float")return!1;return!0}if(e.Reference.selector(r).type=="functions"){if(i.value[0].is==="string")return!0;for(s in i.value)for(o in i.value[s].value){if(i.value[s].value[o].is!=="call")return!1;var u=t.find(e.Reference.selector(r).functions,function(e){return e[0]==i.value[s].value[o].name});if(!u)return!1;if(u[1]!==i.value[s].value[o].args.length)return!1}return!0}if(e.Reference.selector(r).type=="expression")return!0;if(e.Reference.selector(r).validate){var a=!1;for(s=0;s<i.value.length;s++)if(e.Reference.selector(r).type==i.value[s].is&&e.Reference._validateValue[e.Reference.selector(r).validate](n,i.value[s].value))return!0;return a}return e.Reference.selector(r).type==i.value[0].is}}(require("../tree")),function(e){e.Rule=function(n,r,i,s){var o=n.split("/");this.name=o.pop(),this.instance=o.length?o[0]:"__default__",this.value=r instanceof e.Value?r:new e.Value([r]),this.index=i,this.symbolizer=e.Reference.symbolizer(this.name),this.filename=s,this.variable=n.charAt(0)==="@"},e.Rule.prototype.clone=function(){var t=Object.create(e.Rule.prototype);return t.name=this.name,t.value=this.value,t.index=this.index,t.instance=this.instance,t.symbolizer=this.symbolizer,t.filename=this.filename,t.variable=this.variable,t},e.Rule.prototype.updateID=function(){return this.id=this.zoom+"#"+this.name},e.Rule.prototype.toString=function(){return"["+e.Zoom.toString(this.zoom)+"] "+this.name+": "+this.value},e.Rule.prototype.toXML=function(t,n,r,i){if(!e.Reference.validSelector(this.name))return t.error({message:"Unrecognized rule: "+this.name,index:this.index,type:"syntax",filename:this.filename});if(this.value instanceof e.Value&&!e.Reference.validValue(t,this.name,this.value))return e.Reference.selector(this.name)?t.error({message:"Invalid value for "+this.name+", a valid "+(e.Reference.selector(this.name).validate||e.Reference.selector(this.name).type)+" is expected. "+this.value+" was given.",index:this.index,type:"syntax",filename:this.filename}):t.error({message:"Unrecognized property: "+this.name,index:this.index,type:"syntax",filename:this.filename});if(this.variable)return"";if(e.Reference.isFont(this.name)&&this.value.value.length>1){var s=e._getFontSet(t,this.value.value);return'fontset-name="'+s.name+'"'}return n?this.value.toString(t,this.name,r):e.Reference.selectorName(this.name)+'="'+this.value.toString(t,this.name)+'"'},e.Rule.prototype.eval=function(t){return new e.Rule(this.name,this.value.eval(t),this.index,this.filename)}}(require("../tree")),function(e){e.Ruleset=function(t,n){this.selectors=t,this.rules=n,this._lookups={}},e.Ruleset.prototype={eval:function(t){var n=new e.Ruleset(this.selectors,this.rules.slice(0));n.root=this.root,t.frames.unshift(n);if(n.root)for(var r=0;r<n.rules.length;r++)n.rules[r]instanceof e.Import&&Array.prototype.splice.apply(n.rules,[r,1].concat(n.rules[r].eval(t)));for(var r=0,i;r<n.rules.length;r++)i=n.rules[r],n.rules[r]=i.eval?i.eval(t):i;return t.frames.shift(),n},match:function(e){return!e||e.length===0},variables:function(){return this._variables?this._variables:this._variables=this.rules.reduce(function(t,n){return n instanceof e.Rule&&n.variable===!0&&(t[n.name]=n),t},{})},variable:function(e){return this.variables()[e]},rulesets:function(){return this._rulesets?this._rulesets:this._rulesets=this.rules.filter(function(t){return t instanceof e.Ruleset})},find:function(t,n){n=n||this;var r=[],i,s,o=t.toString();return o in this._lookups?this._lookups[o]:(this.rulesets().forEach(function(i){if(i!==n)for(var o=0;o<i.selectors.length;o++)if(s=t.match(i.selectors[o])){t.elements.length>1?Array.prototype.push.apply(r,i.find(new e.Selector(null,null,null,t.elements.slice(1)),n)):r.push(i);break}}),this._lookups[o]=r)},flatten:function(t,n,r){var i=[];this.selectors.length===0&&(r.frames=r.frames.concat(this.rules));for(var s=0;s<this.selectors.length;s++){var o=this.selectors[s];if(!o.filters)continue;if(n.length)for(var u=0;u<n.length;u++){var a=n[u],f=a.filters.cloneWith(o.filters);if(f===null){if(a.zoom===(a.zoom&o.zoom)&&a.frame_offset===o.frame_offset&&a.attachment===o.attachment)continue;f=a.filters}else if(!f)continue;var l=Object.create(e.Selector.prototype);l.filters=f,l.zoom=a.zoom&o.zoom,l.frame_offset=o.frame_offset,l.elements=a.elements.concat(o.elements),a.attachment&&o.attachment?l.attachment=a.attachment+"/"+o.attachment:l.attachment=o.attachment||a.attachment,l.conditions=a.conditions+o.conditions,l.index=o.index,i.push(l)}else i.push(o)}var c=[];for(var s=0;s<this.rules.length;s++){var h=this.rules[s];h instanceof e.Ruleset?h.flatten(t,i,r):h instanceof e.Rule?c.push(h):h instanceof e.Invalid&&r.error(h)}var p=c.length?c[0].index:!1;for(var s=0;s<i.length;s++)p!==!1&&(i[s].index=p),t.push(new e.Definition(i[s],c.slice()));return t}}}(require("../tree"));var assert=require("assert");(function(e){e.Selector=function(n,r,i,s,o,u,a){this.elements=s||[],this.attachment=o,this.filters=n||{},this.frame_offset=i,this.zoom=typeof r!="undefined"?r:e.Zoom.all,this.conditions=u,this.index=a},e.Selector.prototype.specificity=function(){return this.elements.reduce(function(e,t){var n=t.specificity();return e[0]+=n[0],e[1]+=n[1],e},[0,0,this.conditions,this.index])}})(require("../tree")),function(e){var t=require("underscore");e.Style=function(t,n,r){this.attachment=n,this.definitions=r,this.name=t+(n!=="__default__"?"-"+n:"")},e.Style.prototype.toXML=function(e){var n={},r=t.flatten(this.definitions.map(function(e){return e.rules.filter(function(e){return e.name==="image-filters"})})),i=t.flatten(this.definitions.map(function(e){return e.rules.filter(function(e){return e.name==="composite-operation"})})),s=t.flatten(this.definitions.map(function(e){return e.rules.filter(function(e){return e.name==="opacity"})})),o=this.definitions.map(function(t){return t.toXML(e,n)}),u="";return r.length&&(u+=' image-filters="'+r.map(function(t){return t.eval(e).toXML(e,!0," ","image-filter")}).join(" ")+'" '),i.length&&(u+=' comp-op="'+i[0].value.eval(e).toString()+'" '),s.length&&(u+=' opacity="'+s[0].value.eval(e).toString()+'" '),'<Style name="'+this.name+'" filter-mode="first" '+u+">\n"+o.join("")+"</Style>"}}(require("../tree")),function(e){e.URL=function(t,n){this.value=t,this.paths=n,this.is="uri"},e.URL.prototype={toString:function(){return this.value.toString()},eval:function(t){return new e.URL(this.value.eval(t),this.paths)}}}(require("../tree")),function(e){e.Value=function(t){this.value=t,this.is="value"},e.Value.prototype={eval:function(t){return this.value.length===1?this.value[0].eval(t):new e.Value(this.value.map(function(e){return e.eval(t)}))},toString:function(e,t,n,r){return this.value.map(function(t){return t.toString(e,r)}).join(n||", ")},clone:function(){var t=Object.create(e.Value.prototype);return Array.isArray(t)?t.value=this.value.slice():t.value=this.value,t.is=this.is,t}}}(require("../tree")),function(e){e.Variable=function(t,n,r){this.name=t,this.index=n,this.filename=r},e.Variable.prototype={eval:function(e){var t,n,r=this,i=this.name;if(this._css)return this._css;var s=e.frames.filter(function(e){return e.name==r.name});return s.length?s[0].value.eval(e):(e.error({message:"variable "+this.name+" is undefined",index:this.index,type:"runtime",filename:this.filename}),{is:"undefined",value:"undefined"})}}}(require("../tree"));var tree=require("../tree");tree.Zoom=function(e,t,n){t=parseInt(t,10);if(t>tree.Zoom.maxZoom||t<0)throw{message:"Only zoom levels between 0 and "+tree.Zoom.maxZoom+" supported.",index:n};var r=0,i=Infinity,s=0;switch(e){case"=":return 1<<t;case">":r=t+1;break;case">=":r=t;break;case"<":i=t-1;break;case"<=":i=t}for(var o=0;o<=tree.Zoom.maxZoom;o++)o>=r&&o<=i&&(s|=1<<o);return s},tree.Zoom.all=8388607,tree.Zoom.maxZoom=22,tree.Zoom.ranges={0:1e9,1:5e8,2:2e8,3:1e8,4:5e7,5:25e6,6:125e5,7:65e5,8:3e6,9:15e5,10:75e4,11:4e5,12:2e5,13:1e5,14:5e4,15:25e3,16:12500,17:5e3,18:2500,19:1500,20:750,21:500,22:250,23:100},tree.Zoom.toXML=function(e){var t=[];if(e!=tree.Zoom.all){var n=null,r=null;for(var i=0;i<=tree.Zoom.maxZoom;i++)e&1<<i&&(n===null&&(n=i),r=i);n>0&&t.push(" <MaxScaleDenominator>"+tree.Zoom.ranges[n]+"</MaxScaleDenominator>\n"),r<22&&t.push(" <MinScaleDenominator>"+tree.Zoom.ranges[r+1]+"</MinScaleDenominator>\n")}return t},tree.Zoom.toString=function(e){var t="";for(var n=0;n<=tree.Zoom.maxZoom;n++)t+=e&1<<n?"X":".";return t},function(e){function i(t){return e.functions.hsla(t.h,t.s,t.l,t.a)}function s(t){if(t instanceof e.Dimension)return parseFloat(t.unit=="%"?t.value/100:t.value);if(typeof t=="number")return t;throw new Error("Color functions take numbers as parameters.")}function o(e){return Math.min(1,Math.max(0,e))}e.functions={rgb:function(e,t,n){return this.rgba(e,t,n,1)},rgba:function(t,n,r,i){var o=[t,n,r].map(function(e){return s(e)});return i=s(i),new e.Color(o,i)},hsl:function(e,t,n){return this.hsla(e,t,n,1)},hsla:function(e,t,n,r){function u(e){return e=e<0?e+1:e>1?e-1:e,e*6<1?o+(i-o)*e*6:e*2<1?i:e*3<2?o+(i-o)*(2/3-e)*6:o}e=s(e)%360/360,t=s(t),n=s(n),r=s(r);var i=n<=.5?n*(t+1):n+t-n*t,o=n*2-i;return this.rgba(u(e+1/3)*255,u(e)*255,u(e-1/3)*255,r)},hue:function(t){return new e.Dimension(Math.round(t.toHSL().h))},saturation:function(t){return new e.Dimension(Math.round(t.toHSL().s*100),"%")},lightness:function(t){return new e.Dimension(Math.round(t.toHSL().l*100),"%")},alpha:function(t){return new e.Dimension(t.toHSL().a)},saturate:function(e,t){var n=e.toHSL();return n.s+=t.value/100,n.s=o(n.s),i(n)},desaturate:function(e,t){var n=e.toHSL();return n.s-=t.value/100,n.s=o(n.s),i(n)},lighten:function(e,t){var n=e.toHSL();return n.l+=t.value/100,n.l=o(n.l),i(n)},darken:function(e,t){var n=e.toHSL();return n.l-=t.value/100,n.l=o(n.l),i(n)},fadein:function(e,t){var n=e.toHSL();return n.a+=t.value/100,n.a=o(n.a),i(n)},fadeout:function(e,t){var n=e.toHSL();return n.a-=t.value/100,n.a=o(n.a),i(n)},spin:function(e,t){var n=e.toHSL(),r=(n.h+t.value)%360;return n.h=r<0?360+r:r,i(n)},replace:function(e,t,n){return e.is==="field"?e.toString+".replace("+t.toString()+", "+n.toString()+")":e.replace(t,n)},mix:function(t,n,r){var i=r.value/100,s=i*2-1,o=t.toHSL().a-n.toHSL().a,u=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,a=1-u,f=[t.rgb[0]*u+n.rgb[0]*a,t.rgb[1]*u+n.rgb[1]*a,t.rgb[2]*u+n.rgb[2]*a],l=t.alpha*i+n.alpha*(1-i);return new e.Color(f,l)},greyscale:function(t){return this.desaturate(t,new e.Dimension(100))},"%":function(t){var n=Array.prototype.slice.call(arguments,1),r=t.value;for(var i=0;i<n.length;i++)r=r.replace(/%s/,n[i].value).replace(/%[da]/,n[i].toString());return r=r.replace(/%%/g,"%"),new e.Quoted(r)}};var t=["emboss","blur","gray","sobel","edge-detect","x-gradient","y-gradient","sharpen"];for(var n=0;n<t.length;n++){var r=t[n];e.functions[r]=function(t){return function(){return new e.ImageFilter(t)}}(r)}e.functions["agg-stack-blur"]=function(t,n){return new e.ImageFilter("agg-stack-blur",[t,n])}}(require("./tree")),function(carto){function CartoCSS(e,t){this.options=t||{},e&&this.setStyle(e)}var tree=require("./tree"),_=require("underscore");tree.Value.prototype.toJS=function(){var e=this.eval(),t=e.toString();return e.is==="color"||e.is==="uri"||e.is==="string"||e.is==="keyword"?t="'"+t+"'":e.is==="field"&&(t=t.replace(/\[(.*)\]/g,"data['$1']")),"_value = "+t+";"},Object.defineProperty(tree.Filterset.prototype,"toJS",{enumerable:!1,value:function(e){var t={"=":"==="};return _.map(this,function(e){var n=e.op;n in t&&(n=t[n]);var r=e.val;e._val!==undefined&&(r=e._val.toString(!0));var i="data";return i+"."+e.key+" "+n+" "+r}).join(" && ")}}),tree.Definition.prototype.toJS=function(){var e={},t="("+this.zoom+" & (1 << ctx.zoom))",n=this.frame_offset,r=this.filters.toJS(),i=[t];return r&&i.push(r),n&&i.push('ctx["frame-offset"] === '+n),r=i.join(" && "),_.each(this.rules,function(t){if(t instanceof tree.Rule)e[t.name]=e[t.name]||[],r?e[t.name].push("if("+r+"){"+t.value.toJS()+"}"):e[t.name].push(t.value.toJS());else if(t instanceof tree.Ruleset){var n=t.toJS();for(var i in n){e[i]=e[i]||[];for(var s in n[i])e[i].push(n[i][s])}}}),e},CartoCSS.Layer=function(e,t){this.options=t,this.shader=e},CartoCSS.renderers={},CartoCSS.renderers.svg={maps:{},transform:function(e){var t={};for(var n in e){var r=this.maps[n];r?t[r]=e[n]:t[n]=e[n]}return t}},CartoCSS.renderers["canvas-2d"]={maps:{"marker-width":"point-radius","marker-line-color":"strokeStyle","marker-line-width":"lineWidth","marker-line-opacity":"strokeOpacity","marker-fill-opacity":"fillOpacity","marker-opacity":"fillOpacity","marker-fill":"fillStyle","marker-file":function(e){var t=new Image;return t.src=e,t},"point-color":"fillStyle","point-file":function(e){var t=new Image;return t.src=e,t},"line-color":"strokeStyle","line-width":"lineWidth","line-opacity":"globalAlpha","polygon-fill":"fillStyle","polygon-opacity":"globalAlpha","comp-op":"comp-op"},transform:function(e){var t={};for(var n in e){var r=this.maps[n];r?typeof r=="function"?t[n]=r(e[n]):t[r]=e[n]:t[n]=e[n]}return t}};var renderer=CartoCSS.renderers.svg,ref=require("mapnik-reference").version.latest,to_load=["polygon","line","point","markers"];for(var ss in to_load){var s=to_load[ss];for(var i in ref.symbolizers[s])renderer.maps[ref.symbolizers[s][i].css]=i}CartoCSS.Layer.prototype={fullName:function(){return this.shader.attachment},name:function(){return this.fullName().split("::")[0]},frames:function(){return this.shader.frames},attachment:function(){return this.fullName().split("::")[1]},eval:function(e){var t=this.shader[e];if(!t)return;return t({},{zoom:0,"frame-offset":0})},getStyle:function(e,t,n){var r={};for(var i in this.shader)i!=="attachment"&&i!=="zoom"&&i!=="frames"&&(r[i]=this.shader[i](t,n));return CartoCSS.renderers[e].transform(r)},filter:function(e,t,n){for(var r in this.shader){var i=this.shader[r](t,n);if(i)return!0}return!1},transformGeometry:function(e){return e},transformGeometries:function(e){return e}},CartoCSS.prototype={setStyle:function(e){var t=this.parse(e);if(!t)throw new Error(this.parse_env.errors);this.layers=t.map(function(e){return new CartoCSS.Layer(e)})},getLayers:function(){return this.layers},getDefault:function(){return this.findLayer({attachment:"__default__"})},findLayer:function(e){return _.find(this.layers,function(t){for(var n in e){var r=t[n];typeof r=="function"&&(r=r.call(t));if(e[n]!==r)return!1}return!0})},_createFn:function(e){var t=e.join("\n");return this.options.debug&&console.log(t),Function("data","ctx","var _value = null; "+t+"; return _value; ")},_compile:function(shader){typeof shader=="string"&&(shader=eval("(function() { return "+shader+"; })()")),this.shader_src=shader;for(var attr in shader){var c=mapper[attr];c&&(this.compiled[c]=eval("(function() { return shader[attr]; })();"))}},parse:function(e){var t={frames:[],errors:[],error:function(e){this.errors.push(e)}};this.parse_env=t;var n=null;try{n=(new carto.Parser(t)).parse(e)}catch(r){console.log(r.stack),t.errors.push(r.message);return}if(n){var i=n.toList(t);i.reverse();var s={};for(var o=0;o<i.length;++o){var u=i[o],a=u.elements[0]+"::"+u.attachment,f=s[a]=s[a]||{};f.frames=[],f.zoom=tree.Zoom.all;var l=u.toJS();for(var c in l)(f[c]=f[c]||[]).push(l[c].join("\n"))}var h=[],p={};for(var o=0;o<i.length;++o){var u=i[o],d=u.elements[0]+"::"+u.attachment,f=s[d];if(!p[d]){for(var v in f)v!=="zoom"&&v!=="frames"&&(this.options.debug&&console.log("****",v),f[v]=this._createFn(f[v]));f.attachment=d,h.push(f),p[d]=!0}f.zoom|=u.zoom,f.frames.push(u.frame_offset)}for(o=0;o<h.length;++o)h[o].frames=_.uniq(h[o].frames);return h}return null}},carto.RendererJS=function(e){this.options=e||{},this.options.mapnik_version=this.options.mapnik_version||"latest"},carto.RendererJS.prototype.render=function(t,n){return tree.Reference.setVersion(this.options.mapnik_version),new CartoCSS(t,this.options)},typeof module!="undefined"&&(module.exports=carto.RendererJS)}(require("../carto")),function(e){function r(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,_.defaults(this.options,{animationDelay:0,maxDelta:.2,loop:!0}),this.rescale()}e.torque=e.torque||{};var t=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(){return this.running},stop:function(){this.pause(),this.time(0)},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=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){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.rescale()},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,n(this._tick)},_tick:function(){var e=+(new Date),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}(typeof exports=="undefined"?this:exports),function(e){e.torque=e.torque||{};var t={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:"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)"}},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]}};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]=[]);return r.push(t),this},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));return this},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);return this},t.callbacks=function(e){return this._evt_callbacks&&this._evt_callbacks[e]||[]},e.torque.Event=t,e.torque.extend=function(e,t){for(var n in t)e[n]=t[n];return e},e.torque.clone=function(t){return e.torque.extend({},t)},e.torque.isArray=function(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)=="[object Array]"},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||{},e.torque.math={clamp:t,linear:r,invLinear:n}}(typeof exports=="undefined"?this:exports),function(e){function n(e,t,n){return t!==null&&(e=Math.max(e,t)),n!==null&&(e=Math.min(e,n)),e}function r(e){return e*(Math.PI/180)}function i(e){return e/(Math.PI/180)}var t=function(e,t){this.x=e||0,this.y=t||0},s=e.torque.Mercator=function(){this._tileSize=256,this._pixelOrigin=new t(this._tileSize/2,this._tileSize/2),this._pixelsPerLonDegree=this._tileSize/360,this._pixelsPerLonRadian=this._tileSize/(2*Math.PI)};s.prototype._fromLatLonToPoint=function(e,i){var s=new t(0,0),o=this._pixelOrigin;s.x=o.x+i*this._pixelsPerLonDegree;var u=n(Math.sin(r(e)),-0.9999,.9999);return s.y=o.y+.5*Math.log((1+u)/(1-u))*-this._pixelsPerLonRadian,s},s.prototype._fromPointToLatLon=function(e){var t=this,n=t._pixelOrigin,r=(e.x-n.x)/t._pixelsPerLonDegree,s=(e.y-n.y)/-t._pixelsPerLonRadian,o=i(2*Math.atan(Math.exp(s))-Math.PI/2);return{lat:o,lon:r}},s.prototype._tilePixelPos=function(e,t){return{x:e*this._tileSize,y:t*this._tileSize}},s.prototype.tilePixelBBox=function(e,n,r,i,s,o){o=o||1;var u=1<<r,a=o/u;return i=(e*this._tileSize+i)/u,s=(n*this._tileSize+s)/u,[this._fromPointToLatLon(new t(i,s+a)),this._fromPointToLatLon(new t(i+a,s))]},s.prototype.tileBBox=function(e,n,r,i){var s=1<<r;i=i||0;var o=(this._tileSize+i*2)/s,u=(e*this._tileSize-i)/s,a=(n*this._tileSize-i)/s;return[this._fromPointToLatLon(new t(u,a+o)),this._fromPointToLatLon(new t(u+o,a))]},s.prototype.latLonToTilePoint=function(e,n,r,i,s){var o=1<<s,u=this._fromLatLonToPoint(e,n),a=new t(u.x*o,u.y*o),f=this._tilePixelPos(r,i);return new t(Math.round(a.x-f.x),Math.round(a.y-f.y))}}(typeof exports=="undefined"?this:exports),function(e){function n(){}function r(e){this.t0=null,this.name=e,this.count=0}var t=1024;n.metrics={},n.get=function(e){return n.metrics[e]||{max:0,min:Number.MAX_VALUE,avg:0,total:0,count:0,history:typeof Float32Array!="undefined"?new Float32Array(t):[]}},n.new_value=function(e,r){var i=n.metrics[e]=n.get(e);i.max=Math.max(i.max,r),i.min=Math.min(i.min,r),i.total+=r,++i.count,i.avg=i.total/i.count,i.history[i.count%t]=r},n.print_stats=function(){for(k in n.metrics){var e=n.metrics[k];console.log(" === "+k+" === "),console.log(" max: "+e.max),console.log(" min: "+e.min),console.log(" avg: "+e.avg),console.log(" count: "+e.count),console.log(" total: "+e.total)}},r.prototype={start:function(){return this.t0=+(new Date),this},_elapsed:function(){return+(new Date)-this.t0},end:function(){this.t0!==null&&(n.new_value(this.name,this._elapsed()),this.t0=null)},inc:function(e){e=e===undefined?1:e,n.new_value(this.name,n.get(this.name).count+(e?e:0))},dec:function(e){e=e===undefined?1:e,this.inc(-e)},mark:function(){++this.count;if(this.t0===null){this.start();return}var e=this._elapsed();e>1&&(n.new_value(this.name,this.count),this.count=0,this.start())}},n.metric=function(e){return new r(e)},e.Profiler=n}(typeof exports=="undefined"?this:exports),function(e){function o(e){for(var t=1;t<arguments.length;++t){var n=arguments[t];for(var r in n)e=e.replace(RegExp("\\{"+r+"\\}","g"),n[r])}return e}var t=e.torque=e.torque||{},n=e.torque.providers=e.torque.providers||{},r=t.types.Uint8Array,i=t.types.Int32Array,s=t.types.Uint32Array,u=function(e){this._ready=!1,this._tileQueue=[],this.options=e,this.options.is_time=this.options.is_time===undefined?!0:this.options.is_time,this.options.tiler_protocol=e.tiler_protocol||"http",this.options.tiler_domain=e.tiler_domain||"cartodb.com",this.options.tiler_port=e.tiler_port||80,this.options.data_aggregation&&(this.options.cumulative=this.options.data_aggregation==="cumulative");if(e.resolution===undefined)throw new Error("resolution should be provided");if(e.steps===undefined)throw new Error("steps should be provided");e.start===undefined?this._fetchKeySpan():this._setReady(!0)};u.prototype={proccessTile:function(e,t,n){var o,u=new r(e.length),a=new r(e.length),f=Profiler.metric("ProviderJSON:mem"),l=Profiler.metric("ProviderJSON:point_count"),c=Profiler.metric("ProviderJSON:process_time").start(),h=0,p=-1;for(o=0;o<e.length;++o){var d=e[o];h+=d.dates__uint16.length;for(var v=0;v<d.dates__uint16.length;++v)p=Math.max(p,d.dates__uint16[v])}this.options.cumulative&&(h=(1+p)*e.length);var m=this.options.cumulative?s:r,g=new i(p+1),y=new i(p+1),b=new(this.options.valueDataType||m)(h),w=new s(h);f.inc(4*p+4*p+h+h*4),l.inc(e.length);var E={};for(var o=0;o<e.length;++o){var d=e[o];u[o]=d.x__uint8*this.options.resolution,d.y__uint8===-1?a[o]=0:a[o]=d.y__uint8*this.options.resolution;var h=d.dates__uint16,S=d.vals__uint8;if(!this.options.cumulative)for(var x=0,T=h.length;x<T;++x){var N=E[h[x]]||(E[h[x]]=[]);this.options.cumulative&&(S[x]+=prev_val),prev_val=S[x],N.push([o,S[x]])}else{var C={};for(var x=0,T=h.length;x<T;++x)C[h[x]]=S[x];var k=0;for(var x=h[0];x<=p;++x){var N=E[x]||(E[x]=[]),L=C[x];L&&(k+=L),N.push([o,k])}}}var A=0,O=0,M=0;for(var M=0;M<=p;++M){var _=0,D=E[M];if(D)for(var o=0;o<D.length;++o){var N=D[o];++_,w[A]=N[0],b[A]=N[1],++A}g[M]=O,y[M]=_,O+=_}return c.end(),{x:u,y:a,z:n,coord:{x:t.x,y:t.y,z:n},timeCount:y,timeIndex:g,renderDataPos:w,renderData:b,maxDate:p}},_host:function(){var e=this.options,t=e.sql_api_port,n=(e.user_name||e.user)+"."+(e.sql_api_domain||"cartodb.com")+(t?":"+t:""),r=e.sql_api_protocol||"http";return this.options.url||r+"://"+n+"/api/v2/sql"},url:function(e){var t=this.options,n=t.sql_api_protocol||"http";if(!this.options.cdn_url)return this._host();var r=n+"://";e&&(r+=e+".");var i=t.cdn_url;if(!i.http&&!i.https)throw new Error("cdn_host should contain http and/or https entries");return r+=i[n]+"/"+(t.user_name||t.user)+"/api/v2/sql",r},_hash:function(e){var t=0;if(!e||e.length==0)return t;for(var n=0,r=e.length;n<r;++n)t=(t<<5)-t+e.charCodeAt(n)|0;return t},_extraParams:function(){if(this.options.extra_params){var e=[];for(var t in this.options.extra_params){var n=this.options.extra_params[t];n&&e.push(t+"="+encodeURIComponent(n))}return e.join("&")}return null},isHttps:function(){return this.options.sql_api_protocol&&this.options.sql_api_protocol==="https"},sql:function(e,n,r){r=r||{};var i=this.options.subdomains||"0123";this.isHttps()&&(i=[null]);var s;r.no_cdn?s=this._host():s=this.url(i[Math.abs(this._hash(e))%i.length]);var o=this._extraParams();t.net.get(s+"?q="+encodeURIComponent(e)+(o?"&"+o:""),function(e){r.parseJSON&&(e=JSON.parse(e&&e.responseText)),n&&n(e)})},getTileData:function(e,t,n){this._ready?this._getTileData(e,t,n):this._tileQueue.push([e,t,n])},_setReady:function(e){this._ready=!0,this._processQueue(),this.options.ready&&this.options.ready()},_processQueue:function(){var e;while(e=this._tileQueue.pop())this._getTileData.apply(this,e)},_getTileData:function(e,t,n){var r=Profiler.metric("ProviderJSON:tile_fetch_time").start();this.table=this.options.table;var i=1<<t,s=this.options.column;this.options.is_time&&(s=o("date_part('epoch', {column})",this.options));var u="WITH par AS ( SELECT CDB_XYZ_Resolution({zoom})*{resolution} as res, 256/{resolution} as tile_size, CDB_XYZ_Extent({x}, {y}, {zoom}) as ext ),cte AS ( SELECT ST_SnapToGrid(i.the_geom_webmercator, p.res) g, {countby} c, floor(({column_conv} - {start})/{step}) d FROM ({_sql}) i, par p WHERE i.the_geom_webmercator && p.ext GROUP BY g, d) SELECT (st_x(g)-st_xmin(p.ext))/p.res x__uint8, (st_y(g)-st_ymin(p.ext))/p.res y__uint8, array_agg(c) vals__uint8, array_agg(d) dates__uint16 FROM cte, par p where (st_y(g)-st_ymin(p.ext))/p.res < tile_size and (st_x(g)-st_xmin(p.ext))/p.res < tile_size GROUP BY x__uint8, y__uint8",a=o(u,this.options,{zoom:t,x:e.x,y:e.y,column_conv:s,_sql:this.getSQL()}),f=this;this.sql(a,function(i){if(i){var s=JSON.parse(i.responseText).rows;n(f.proccessTile(s,e,t))}else n(null);r.end()})},getKeySpan:function(){return{start:this.options.start*1e3,end:this.options.end*1e3,step:this.options.step,steps:this.options.steps,columnType:this.options.is_time?"date":"number"}},setColumn:function(e,t){this.options.column=e,this.options.is_time=t===undefined?!0:!1,this.reload()},setResolution:function(e){this.options.resolution=e},setOptions:function(e){var t=!1;e.resolution!==undefined&&e.resolution!==this.options.resolution&&(this.options.resolution=e.resolution,t=!0),e.steps!==undefined&&e.steps!==this.options.steps&&(this.setSteps(e.steps,{silent:!0}),t=!0),e.column!==undefined&&e.column!==this.options.column&&(this.options.column=e.column,t=!0),e.countby!==undefined&&e.countby!==this.options.countby&&(this.options.countby=e.countby,t=!0);if(e.data_aggregation!==undefined){var n=e.data_aggregation==="cumulative";this.options.cumulative!==n&&(this.options.cumulative=n,t=!0)}return t&&this.reload(),t},reload:function(){this._ready=!1,this._fetchKeySpan()},setSQL:function(e){this.options.sql!=e&&(this.options.sql=e,this.reload())},getSteps:function(){return Math.min(this.options.steps,this.options.data_steps)},setSteps:function(e,t){t=t||{},this.options.steps!==e&&(this.options.steps=e,this.options.step=(this.options.end-this.options.start)/this.getSteps(),this.options.step=this.options.step||1,t.silent||this.reload())},getBounds:function(){return this.options.bounds},getSQL:function(){return this.options.sql||"select * from "+this.options.table},_tilerHost:function(){var e=this.options,t=e.user_name||e.user;return e.tiler_protocol+"://"+(t?t+".":"")+e.tiler_domain+(e.tiler_port!=""?":"+e.tiler_port:"")},_fetchUpdateAt:function(e){var n=this,r={version:"1.0.1",stat_tag:this.options.stat_tag||"torque",layers:[{type:"cartodb",options:{cartocss_version:"2.1.1",cartocss:"#layer {}",sql:this.getSQL()}}]},i=this._tilerHost()+"/tiles/layergroup",s=this._extraParams();s&&(s=s.replace("api_key=","map_key=")),i=i+"?config="+encodeURIComponent(JSON.stringify(r))+"&callback=?"+(s?"&"+s:""),t.net.jsonp(i,function(t){var r=o("select * from ({sql}) __torque_wrap_sql limit 0",{sql:n.getSQL()});n.sql(r,function(n){t&&e({updated_at:t.last_updated,fields:n.fields})},{parseJSON:!0})})},_fetchKeySpan:function(){var e=this,t,n,r,i;this._fetchUpdateAt(function(s){if(!s)return;e.options.extra_params=e.options.extra_params||{},e.options.extra_params.last_updated=s.updated_at||0,e.options.extra_params.cache_policy="persist",e.options.is_time=s.fields[e.options.column].type==="date";var u=e.options.column;e.options.is_time?(r="date_part('epoch', max({column}))",i="date_part('epoch', min({column}))",u=o("date_part('epoch', {column})",e.options)):(r="max({column})",i="min({column})"),t=o(r,{column:e.options.column}),n=o(i,{column:e.options.column});var a=" SELECT st_xmax(st_envelope(st_collect(the_geom))) xmax, st_ymax(st_envelope(st_collect(the_geom))) ymax, st_xmin(st_envelope(st_collect(the_geom))) xmin, st_ymin(st_envelope(st_collect(the_geom))) ymin, count(*) as num_steps, {max_col} max_date, {min_col} min_date FROM ({sql}) __torque_wrap_sql ",f=o(a,{max_col:t,min_col:n,column:u,sql:e.getSQL()});e.sql(f,function(t){t=t.rows[0],e.options.start=t.min_date,e.options.end=t.max_date,e.options.step=(t.max_date-t.min_date)/Math.min(e.options.steps,t.num_steps>>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.providers.json=u}(typeof exports=="undefined"?this:exports),function(e){function u(e,t){for(var n=1;n<arguments.length;++n){var t=arguments[n];for(var r in t)e=e.replace(RegExp("\\{"+r+"\\}","g"),t[r])}return e}var t=e.torque=e.torque||{},n=e.torque.providers=e.torque.providers||{},i=t.types.Uint8Array,s=t.types.Int32Array,o=t.types.Uint32Array,a=function(e){this.options=e};a.prototype={aggregateByKey:function(e){function t(e){var t=3,n=e.data[2],r={};for(var i=0;i<n;++i)r[e.data[t+i]]=e.data[t+n+i];return r}var n={};for(r=0;r<e.length;++r){var i=t(e[r]);for(var s in i)n[s]=n[s]||0,n[s]+=i[s]}return n},proccessTile:function(e,t,n){function l(e){var t=3,n={x:e.data[0]*f.options.resolution,y:e.data[1]*f.options.resolution,valuesCount:e.data[2],times:[],values:[]};for(var r=0;r<n.valuesCount;++r)n.times.push(e.data[t+r]),n.values.push(e.data[t+n.valuesCount+r]);if(f.options.cumulative)for(var r=1;r<n.valuesCount;++r)n.values[r]+=n.values[r-1];return n}var r,u=new i(e.length),a=new i(e.length),f=this;for(r=0;r<e.length;++r)e[r]=l(e[r]);var c=0,h=0;for(r=0;r<e.length;++r){var p=e[r];c+=p.times.length;for(var d=0;d<p.times.length;++d)h=Math.max(h,p.times[d])}var v=new s(h+1),m=new s(h+1),g=new(this.options.valueDataType||i)(c),y=new o(c),b={};for(var r=0;r<e.length;++r){var p=e[r];u[r]=p.x,a[r]=p.y;var c=p.times,w=p.values;for(var E=0,S=c.length;E<S;++E){var x=b[c[E]]||(b[c[E]]=[]);x.push([r,w[E]])}}var T=0,N=0,C=0;for(var C=0;C<=h;++C){var k=0,L=b[C];if(L)for(var r=0;r<L.length;++r){var x=L[r];++k,y[T]=x[0],g[T]=x[1],++T}v[C]=N,m[C]=k,N+=k}return{x:u,y:a,coord:{x:t.x,y:t.y,z:n},timeCount:m,timeIndex:v,renderDataPos:y,renderData:g}},url:function(){return this.options.url},tileUrl:function(e,t){var n=this.url(),r=(this.options.subdomains||"abcd")[(e.x+e.y+t)%4];return n.replace("{x}",e.x).replace("{y}",e.y).replace("{z}",t).replace("{s}",r)},getTile:function(e,n,r){var i=this.tileUrl(e,n),s=this,o=Profiler.metric("jsonarray:fetch time");o.start(),t.net.get(i,function(e){o.end(),e&&(e=JSON.parse(e.responseText)),r(e)})},getTileData:function(e,n,r){var i=this.tileUrl(e,n),s=this,o=Profiler.metric("jsonarray:fetch time");o.start(),t.net.get(i,function(t){o.end();var i=null,u=Profiler.metric("jsonarray:processing time"),a=Profiler.metric("jsonarray:parsing time");try{u.start(),a.start();var f=JSON.parse(t.responseText||t.response).rows;a.end(),i=s.proccessTile(f,e,n),u.end()}catch(l){console.error("problem parsing JSON on ",e,n)}r(i)})}},t.providers.JsonArray=a}(typeof exports=="undefined"?this:exports),function(e){function o(e){for(var t=1;t<arguments.length;++t){var n=arguments[t];for(var r in n)e=e.replace(RegExp("\\{"+r+"\\}","g"),n[r])}return e}var t=e.torque=e.torque||{},n=e.torque.providers=e.torque.providers||{},r=t.types.Uint8Array,i=t.types.Int32Array,s=t.types.Uint32Array,u=function(e){this._ready=!1,this._tileQueue=[],this.options=e,this.options.is_time=this.options.is_time===undefined?!0:this.options.is_time,this.options.tiler_protocol=e.tiler_protocol||"http",this.options.tiler_domain=e.tiler_domain||"cartodb.com",this.options.tiler_port=e.tiler_port||80,this.options.data_aggregation&&(this.options.cumulative=this.options.data_aggregation==="cumulative");if(this.options.auth_token){var t=this.options.extra_params||(this.options.extra_params={});t.auth_token=this.options.auth_token}this._fetchMap()};u.prototype={proccessTile:function(e,t,n){var o,u=new r(e.length),a=new r(e.length),f=Profiler.metric("torque.provider.windshaft.mem"),l=Profiler.metric("torque.provider.windshaft.points"),c=Profiler.metric("torque.provider.windshaft.process_time").start(),h=0,p=-1;for(o=0;o<e.length;++o){var d=e[o];h+=d.dates__uint16.length;for(var v=0;v<d.dates__uint16.length;++v)p=Math.max(p,d.dates__uint16[v])}this.options.cumulative&&(h=(1+p)*e.length);var m=this.options.cumulative?s:r,g=new i(p+1),y=new i(p+1),b=new(this.options.valueDataType||m)(h),w=new s(h);f.inc(4*p+4*p+h+h*4),l.inc(e.length);var E={};for(var o=0;o<e.length;++o){var d=e[o];u[o]=d.x__uint8*this.options.resolution,d.y__uint8===-1?a[o]=0:a[o]=d.y__uint8*this.options.resolution;var h=d.dates__uint16,S=d.vals__uint8;if(!this.options.cumulative)for(var x=0,T=h.length;x<T;++x){var N=E[h[x]]||(E[h[x]]=[]);this.options.cumulative&&(S[x]+=prev_val),prev_val=S[x],N.push([o,S[x]])}else{var C={};for(var x=0,T=h.length;x<T;++x)C[h[x]]=S[x];var k=0;for(var x=h[0];x<=p;++x){var N=E[x]||(E[x]=[]),L=C[x];L&&(k+=L),N.push([o,k])}}}var A=0,O=0,M=0;for(var M=0;M<=p;++M){var _=0,D=E[M];if(D)for(var o=0;o<D.length;++o){var N=D[o];++_,w[A]=N[0],b[A]=N[1],++A}g[M]=O,y[M]=_,O+=_}return c.end(),{x:u,y:a,z:n,coord:{x:t.x,y:t.y,z:n},timeCount:y,timeIndex:g,renderDataPos:w,renderData:b,maxDate:p}},setSteps:function(e,t){t=t||{},this.options.steps!==e&&(this.options.steps=e,this.options.step=(this.options.end-this.options.start)/this.getSteps(),this.options.step=this.options.step||1,t.silent||this.reload())},setOptions:function(e){var t=!1;e.resolution!==undefined&&e.resolution!==this.options.resolution&&(this.options.resolution=e.resolution,t=!0),e.steps!==undefined&&e.steps!==this.options.steps&&(this.setSteps(e.steps,{silent:!0}),t=!0),e.column!==undefined&&e.column!==this.options.column&&(this.options.column=e.column,t=!0),e.countby!==undefined&&e.countby!==this.options.countby&&(this.options.countby=e.countby,t=!0);if(e.data_aggregation!==undefined){var n=e.data_aggregation==="cumulative";this.options.cumulative!==n&&(this.options.cumulative=n,t=!0)}return t&&this.reload(),t},_extraParams:function(){if(this.options.extra_params){var e=[];for(var n in this.options.extra_params){var r=this.options.extra_params[n];if(r)if(t.isArray(r))for(var i=0,s=r.length;i<s;i++)e.push(n+"[]="+encodeURIComponent(r[i]));else e.push(n+"="+encodeURIComponent(r))}return e.join("&")}return null},getTileData:function(e,t,n){this._ready?this._getTileData(e,t,n):this._tileQueue.push([e,t,n])},_setReady:function(e){this._ready=!0,this._processQueue(),this.options.ready&&this.options.ready()},_processQueue:function(){var e;while(e=this._tileQueue.pop())this._getTileData.apply(this,e)},_getTileData:function(e,n,r){var i=this,s=Profiler.metric("torque.provider.windshaft.tile.fetch").start(),o=this.options.subdomains||"0123",u=Math.abs(e.x+e.y)%o.length,a=this.templateUrl.replace("{x}",e.x).replace("{y}",e.y).replace("{z}",n).replace("{s}",o[u]),f=this._extraParams();t.net.get(a+(f?"?"+f:""),function(t){s.end();if(t&&t.responseText){var o=JSON.parse(t.responseText);r(i.proccessTile(o,e,n))}else Profiler.metric("torque.provider.windshaft.tile.error").inc(),r(null)})},getKeySpan:function(){return{start:this.options.start,end:this.options.end,step:this.options.step,steps:this.options.steps,columnType:this.options.column_type}},setColumn:function(e,t){this.options.column=e,this.options.is_time=t===undefined?!0:!1,this.reload()},reload:function(){this._ready=!1,this._fetchMap()},getSteps:function(){return Math.min(this.options.steps,this.options.data_steps)},getBounds:function(){return this.options.bounds},getSQL:function(){return this.options.sql||"select * from "+this.options.table},setSQL:function(e){this.options.sql!=e&&(this.options.sql=e,this.reload())},_tilerHost:function(){var e=this.options,t=e.user_name||e.user;return e.tiler_protocol+"://"+(t?t+".":"")+e.tiler_domain+(e.tiler_port!=""?":"+e.tiler_port:"")},url:function(){var e=this.options,t=e.tiler_protocol||"http";if(!this.options.cdn_url||this.options.no_cdn)return this._tilerHost();var n=t+"://";t==="http"&&(n+="{s}.");var r=e.cdn_url;if(!r.http&&!r.https)throw new Error("cdn_host should contain http and/or https entries");return n+=r[t]+"/"+(e.user_name||e.user),n},_generateCartoCSS:function(){var e={"-torque-frame-count":this.options.steps,"-torque-resolution":this.options.resolution,"-torque-aggregation-function":"'"+this.options.countby+"'","-torque-time-attribute":"'"+this.options.column+"'","-torque-data-aggregation":this.options.cumulative?"cumulative":"linear"},t="Map{";for(var n in e)t+=n+":"+e[n]+";";return t+"}"},_fetchMap:function(e){var n=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()}}]};var o=this._extraParams();o&&(o=o.replace("api_key=","map_key=")),i=i+"?config="+encodeURIComponent(JSON.stringify(r))+"&callback=?"+(o?"&"+o:"");var u=Profiler.metric("torque.provider.windshaft.layergroup.time").start();t.net.jsonp(i,function(e){u.end();if(e){var t=Object.keys(e.metadata.torque)[0],r=e.metadata.torque[t];for(var i in r)n.options[i]=r[i];if(e.cdn_url){var s=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)}else Profiler.metric("torque.provider.windshaft.layergroup.error").inc()},{callbackName:n.options.instanciateCallback})}},t.providers.windshaft=u}(typeof exports=="undefined"?this:exports),function(e){function r(e,t,n){function o(){r.removeChild(i),clearTimeout(u),delete window[s]}n=n||{},n.timeout=n.timeout===undefined?1e4:n.timeout;var r=document.getElementsByTagName("head")[0],i=document.createElement("script"),s=n.callbackName||"torque_"+Date.now();window[s]=function(){o(),t.apply(window,arguments)};var u=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)}function i(e,t,r){function o(){var e=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};var i=XMLHttpRequest;window.XDomainRequest&&!("withCredentials"in i)&&/^(http(s)?:)?\/\//.test(e)&&(i=XDomainRequest);var s=new i;return s.open(r.method,e,!0),"onload"in s?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}function s(e,t,n){return i(e,n,{data:t,method:"POST"})}var t=e.torque=e.torque||{};t.net=t.net||{};var n=null;t.net={get:i,post:s,jsonp:r,lastCall:function(){return n}}}(typeof exports=="undefined"?this:exports),function(e){function n(e,n){e.fillStyle=n.fillStyle;var r=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())}function r(e,t){e.fillStyle=t.fillStyle;var n=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))}function i(e,t){var n=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||{};var t=Math.PI*2;e.torque.cartocss=e.torque.cartocss||{},e.torque.cartocss={renderPoint:n,renderSprite:i,renderRectangle:r}}(typeof exports=="undefined"?this:exports),function(e){function r(e,t){if(!e)throw new Error("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),this.TILE_SIZE=256}e.torque=e.torque||{},e.torque.renderer=e.torque.renderer||{};var t=Math.PI*2,n=["#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");r.prototype={setCanvas:function(e){this._canvas=e,this._ctx=e.getContext("2d")},setCartoCSS:function(e){this.setShader((new carto.RendererJS).render(e))},setShader:function(e){this._sprites=[],this._shader=e},clearSpriteCache:function(){this._sprites=[]},generateSprite:function(e,t,n){var r=Profiler.metric("torque.renderer.point.generateSprite").start(),i=e.getStyle("canvas-2d",{value:t},n),s=i["point-radius"];if(!s)throw new Error("marker-width property should be set");var o=document.createElement("canvas"),u=(i.lineWidth||0)+s*2,a=o.getContext("2d"),f=a.width=o.width=a.height=o.height=Math.ceil(u);a.translate(f/2,f/2);if(i["point-file"]||i["marker-file"])torque.cartocss.renderSprite(a,i);else{var l=i["marker-type"];l&&l==="rectangle"?torque.cartocss.renderRectangle(a,i):torque.cartocss.renderPoint(a,i)}r.end(!0);var c=new Image;return c.src=o.toDataURL(),c},renderTile:function(e,t){var n=Profiler.metric("torque.renderer.point.renderLayers").start(),r=this._shader.getLayers();for(var i=0,s=r.length;i<s;++i){var o=r[i];if(o.name()!=="Map"){var u=this._sprites[i]||(this._sprites[i]={});for(var a=0;a<o.frames().length;++a){var f=o.frames()[a],l=u[f]||(u[f]=[]);this._renderTile(e,t-f,f,l,o)}}}n.end(!0)},_renderTile:function(e,t,n,r,i,s){if(!this._canvas)return;var o=Profiler.metric("torque.renderer.point.renderTile").start(),u=this._ctx,a=i.eval("comp-op")||this.options.blendmode;a&&(u.globalCompositeOperation=a),this.options.cumulative&&t>e.maxDate&&(t=e.maxDate);var f=this.options.resolution*(this.TILE_SIZE/this.options.resolution-1),l=e.timeCount[t];if(l){var c=e.timeIndex[t];for(var h=0;h<l;++h){var p=e.renderDataPos[c+h],d=e.renderData[c+h];if(d){var v=r[d];v||(v=r[d]=this.generateSprite(i,d,_.extend({zoom:e.z,"frame-offset":n},s)));var m=e.x[p]-(v.width>>1),g=f-e.y[p];u.drawImage(v,m,g-(v.height>>1))}}}o.end(!0)},setBlendMode:function(e){this.options.blendmode=e},getActivePointsBBox:function(e,t){var n=[],r=new torque.Mercator,i=this.options.resolution*(this.TILE_SIZE/this.options.resolution-1),s=e.timeCount[t],o=e.timeIndex[t];for(var u=0;u<s;++u){var a=e.renderDataPos[o+u],f=e.renderData[o+u];if(f){var l=e.x[a],c=i-e.y[a];n.push(r.tilePixelBBox(e.coord.x,e.coord.y,e.coord.z,l,c))}}return n},getValueFor:function(e,t,n,r){var i=new torque.Mercator,s=this.options.resolution,o=s>>1,u=this.options.resolution*(this.TILE_SIZE/this.options.resolution-1),a=e.timeCount[t],f=e.timeIndex[t];for(var l=0;l<a;++l){var c=e.renderDataPos[f+l],h=e.renderData[f+l];if(h){var p=e.x[c],d=u-e.y[c],v=n+o-p,m=r+o-d;if(v>=0&&v<s&&m>=0&&m<s)return{value:h,bbox:i.tilePixelBBox(e.coord.x,e.coord.y,e.coord.z,p-o,d-o,s)}}}return null}},e.torque.renderer.Point=r}(typeof exports=="undefined"?this:exports),function(e){function r(e,n){this.options=n,carto.tree.Reference.set(torque["torque-reference"]),this.setCanvas(e),this.setCartoCSS(this.options.cartocss||t)}e.torque=e.torque||{},e.torque.renderer=e.torque.renderer||{};var t=["#layer {"," polygon-fill: #FFFF00;"," [value > 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"),n=Math.PI*2;r.prototype={setCartoCSS:function(e){this._cartoCssStyle=(new carto.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<t.length;++u){a=t[u],f=e.timeCount[a];if(f){l=e.timeIndex[a];for(o=0;o<f;++o)s=e.renderDataPos[l+o],r=e.x[s]/c,i=e.y[s]/c,p[r*h+i]+=e.renderData[l+o]}}return n.end(),p},renderTileAccum:function(e,t,n){var r=Profiler.metric("RectangleRender:renderTileAccum").start(),i,s,o,u,a=this.options.resolution,f=this._ctx,l=256/a|0,c=l*l,h=this._colors;this.options.blendmode&&(f.globalCompositeOperation=this.options.blendmode);var p=this._shader["polygon-opacity"]||function(){return 1};for(var d=0;d<c;++d){var v=d,m=e[d];m&&(s=v/l|0,o=v%l,i=this._shader["polygon-fill"]({value:m},{zoom:0}),f.fillStyle=i,u=p({value:m},{zoom:0}),u===null&&(u=1),f.globalAlpha=u,f.fillRect(s*a,256-a-o*a,a,a))}r.end()},renderTile:function(e,t,n,r){if(!this._canvas)return;var i=this.options.resolution,s=this._ctx,o=this._colors,u=e.timeCount[t];if(u){var a=this._canvas.width,f=this._canvas.height,l=e.timeIndex[t];for(var c=0;c<activePixels;++c){var h=e.renderDataPos[l+c],p=e.renderData[l+c];if(p){var d=o[Math.min(p,o.length-1)],v=e.x[h],m=e.y[h];s.fillStyle=d,s.fillRect(v,m,i,i)}}}}},e.torque.renderer.Rectangle=
|
|
r}(typeof exports=="undefined"?this:exports);if(typeof google!="undefined"&&typeof google.maps!="undefined"){function CanvasLayer(e){function n(e,t){return function(){t.apply(e)}}this.isAdded_=!1,this.isAnimated_=!1,this.paneName_=CanvasLayer.DEFAULT_PANE_NAME_,this.updateHandler_=null,this.resizeHandler_=null,this.topLeft_=null,this.centerListener_=null,this.resizeListener_=null,this.needsResize_=!0,this.requestAnimationFrameId_=null;var t=document.createElement("canvas");t.style.position="absolute",t.style.top=0,t.style.left=0,t.style.pointerEvents="none",this.canvas=t,this.repositionFunction_=n(this,this.repositionCanvas_),this.resizeFunction_=n(this,this.resize_),this.requestUpdateFunction_=n(this,this.update_),e&&this.setOptions(e)}CanvasLayer.prototype=new google.maps.OverlayView,CanvasLayer.DEFAULT_PANE_NAME_="overlayLayer",CanvasLayer.CSS_TRANSFORM_=function(){var e=document.createElement("div"),t=["transform","WebkitTransform","MozTransform","OTransform","msTransform"];for(var n=0;n<t.length;n++){var r=t[n];if(e.style[r]!==undefined)return r}return t[0]}(),CanvasLayer.prototype.requestAnimFrame_=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)},CanvasLayer.prototype.cancelAnimFrame_=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(e){},CanvasLayer.prototype.setOptions=function(e){e.animate!==undefined&&this.setAnimate(e.animate),e.paneName!==undefined&&this.setPane(e.paneName),e.updateHandler!==undefined&&this.setUpdateHandler(e.updateHandler),e.resizeHandler!==undefined&&this.setResizeHandler(e.resizeHandler),e.readyHandler&&(this.readyHandler=e.readyHandler)},CanvasLayer.prototype.setAnimate=function(e){this.isAnimated_=!!e,this.isAnimated_&&this.scheduleUpdate()},CanvasLayer.prototype.isAnimated=function(){return this.isAnimated_},CanvasLayer.prototype.setPaneName=function(e){this.paneName_=e,this.setPane_()},CanvasLayer.prototype.getPaneName=function(){return this.paneName_},CanvasLayer.prototype.setPane_=function(){if(!this.isAdded_)return;var e=this.getPanes();if(!e[this.paneName_])throw new Error('"'+this.paneName_+'" is not a valid MapPane name.');e[this.paneName_].appendChild(this.canvas)},CanvasLayer.prototype.setResizeHandler=function(e){this.resizeHandler_=e},CanvasLayer.prototype.setUpdateHandler=function(e){this.updateHandler_=e},CanvasLayer.prototype.onAdd=function(){if(this.isAdded_)return;this.isAdded_=!0,this.setPane_(),this.resizeListener_=google.maps.event.addListener(this.getMap(),"resize",this.resizeFunction_),this.centerListener_=google.maps.event.addListener(this.getMap(),"center_changed",this.repositionFunction_),this.resize_(),this.repositionCanvas_(),this.readyHandler&&this.readyHandler()},CanvasLayer.prototype.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._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,i=new google.maps.LatLng(e.getNorthEast().lat(),e.getSouthWest().lng()),s=new google.maps.LatLng(e.getSouthWest().lat(),e.getNorthEast().lng());this._projection=this._map.getProjection();var o=this._projection.fromLatLngToPoint(i),u=this._projection.fromLatLngToPoint(s),a=new google.maps.Point(Math.floor(o.x*r/n),Math.floor(o.y*r/n)),f=new google.maps.Point(Math.floor(u.x*r/n),Math.floor(u.y*r/n));this._addTilesFromCenterOut(a,f),this._removeOtherTiles(a,f)},_removeOtherTiles:function(e,t){var n,r,i,s,o=this._map.getZoom();for(s in this._tiles)this._tiles.hasOwnProperty(s)&&(n=s.split(":"),r=parseInt(n[0],10),i=parseInt(n[1],10),z=parseInt(n[2],10),(z!==o||r<e.x||r>t.x||i<e.y||i>t.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<<this._map.getZoom();e={x:(e.x%t+t)%t,y:e.y},e=new google.maps.Point(e.x*this.tileSize,e.y*this.tileSize);var n=this._map.getBounds(),r=new google.maps.LatLng(n.getNorthEast().lat(),n.getSouthWest().lng()),i=this._map.getProjection().fromLatLngToPoint(r);return zoom=1<<this._map.getZoom(),i.x=i.x*zoom,i.y=i.y*zoom,new google.maps.Point(e.x-i.x,e.y-i.y)},_addTilesFromCenterOut:function(e,t){function f(e){var t=e.x-r.x,n=e.y-r.y;return t*t+n*n}var n=[],r=new google.maps.Point((e.x+t.x)*.5,(e.y+t.y)*.5),i=this._map.getZoom(),s,o,u;for(s=e.y;s<=t.y;s++)for(o=e.x;o<=t.x;o++)u=new google.maps.Point(o,s),u.zoom=i,this._tileShouldBeLoaded(u)&&n.push(u);var a=n.length;if(a===0)return;n.sort(function(e,t){return f(e)-f(t)}),this._tilesToLoad+=a;for(o=0;o<a;o++){var l=n[o],c=this._tileKey(l);this._tilesLoading[c]=l,this.onTileAdded&&this.onTileAdded(l)}this.onTilesLoading&&this.onTilesLoading()}},torque.GMapsTileLoader=t})(typeof exports=="undefined"?this:exports),function(e){function t(e){var t=this;if(!torque.isBrowserSupported())throw new Error("browser is not supported by torque");this.key=0,this.shader=null,this.ready=!1,this.options=_.extend({},e),_.defaults(this.options,{provider:"windshaft",renderer:"point",resolution:2,steps:100,visible:!0}),e.cartocss&&_.extend(this.options,torque.common.TorqueLayer.optionsFromCartoCSS(e.cartocss)),this.hidden=!this.options.visible,this.animator=new torque.Animator(function(e){var n=e|0;t.key!==n&&t.setKey(n)},torque.clone(this.options)),this.play=this.animator.start.bind(this.animator),this.stop=this.animator.stop.bind(this.animator),this.pause=this.animator.pause.bind(this.animator),this.toggle=this.animator.toggle.bind(this.animator),this.setDuration=this.animator.duration.bind(this.animator),this.isRunning=this.animator.isRunning.bind(this.animator),CanvasLayer.call(this,{map:this.options.map,animate:!1,updateHandler:this.render,readyHandler:this.initialize})}function n(e){this.options=_.extend({},e),CanvasTileLayer.call(this,this._loadTile.bind(this),this.drawTile.bind(this)),this.initialize(e)}if(typeof google=="undefined"||typeof google.maps=="undefined")return;t.prototype=_.extend({},CanvasLayer.prototype,torque.GMapsTileLoader.prototype,torque.Event,{providers:{sql_api:torque.providers.json,url_template:torque.providers.jsonarray,windshaft:torque.providers.windshaft},renderers:{point:torque.renderer.Point,pixel:torque.renderer.Rectangle},initialize:function(){var e=this;this.onTileAdded=this.onTileAdded.bind(this),this.options.ready=function(){e.fire("change:bounds",{bounds:e.provider.getBounds()}),e.animator.steps(e.provider.getSteps()),e.animator.rescale(),e.fire("change:steps",{steps:e.provider.getSteps()}),e.setKey(e.key)},this.provider=new this.providers[this.options.provider](this.options),this.renderer=new this.renderers[this.options.renderer](this.getCanvas(),this.options),this._cacheListener=google.maps.event.addListener(this.options.map,"zoom_changed",function(){e.renderer&&e.renderer.clearSpriteCache()}),this._initTileLoader(this.options.map,this.getProjection()),this.shader&&this.renderer.setShader(this.shader)},hide:function(){return this.hidden?this:(this.pause(),this.clear(),this.hidden=!0,this)},show:function(){return this.hidden?(this.hidden=!1,this.play(),this):this},setSQL:function(e){if(!this.provider||!this.provider.setSQL)throw new Error("this provider does not support SQL");return this.provider.setSQL(e),this._reloadTiles(),this},setBlendMode:function(e){this.renderer&&this.renderer.setBlendMode(e),this.redraw()},setSteps:function(e){this.provider&&this.provider.setSteps(e),this.animator&&this.animator.steps(e),this._reloadTiles()},setColumn:function(e,t){this.provider&&this.provider.setColumn(e,t),this._reloadTiles()},getTimeBounds:function(){return this.provider&&this.provider.getKeySpan()},getCanvas:function(){return this.canvas},onTileAdded:function(e){var t=this;this.provider.getTileData(e,e.zoom,function(n){if(e.zoom!==t.options.map.getZoom())return;t._tileLoaded(e,n),n&&t.redraw()})},clear:function(){var e=this.canvas;e.width=e.width},render:function(){if(this.hidden)return;var e,t,n,r=this.canvas;r.width=r.width;var i=r.getContext("2d");for(e in this._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))},getActivePointsBBox:function(e){var t=[],n=this.options.resolution*(256/this.options.resolution-1);for(var r in this._tiles){var i=this._tiles[r];t=t.concat(this.renderer.getActivePointsBBox(i,e))}return t},setKey:function(e){this.key=e,this.animator.step(e),this.redraw(),this.fire("change:time",{time:this.getTime(),step:this.key})},setStep:function(e){if(e===undefined||e.length!==undefined)throw new Error("setTime only accept scalars");this.setKey(e)},stepToTime:function(e){if(!this.provider)return 0;var t=this.provider.getKeySpan(),n=t.start+(t.end-t.start)*(e/this.provider.getSteps());return new Date(n)},getStep:function(){return this.key},getTime:function(){return this.stepToTime(this.key)},setCartoCSS:function(e){var t=(new carto.RendererJS).render(e);this.shader=t,this.renderer&&this.renderer.setShader(t);var n=torque.common.TorqueLayer.optionsFromLayer(t.findLayer({name:"Map"}));return this.provider&&this.provider.setCartoCSS&&this.provider.setCartoCSS(e),this.provider&&this.provider.setOptions(n)&&this._reloadTiles(),_.extend(this.options,n),n.animationDuration&&this.animator.duration(n.animationDuration),this.redraw(),this},redraw:function(){this.scheduleUpdate()},onRemove:function(){CanvasLayer.prototype.onRemove.call(this),this.animator.stop(),this._removeTileLoader(),google.maps.event.removeListener(this._cacheListener)}}),n.prototype=_.extend({},CanvasTileLayer.prototype,{providers:{sql_api:torque.providers.json,url_template:torque.providers.JsonArray},renderers:{point:torque.renderer.Point,pixel:torque.renderer.Rectangle},initialize:function(e){var t=this;this.key=0,this.options.renderer=this.options.renderer||"pixel",this.options.provider=this.options.provider||"sql_api",this.provider=new this.providers[this.options.provider](e),this.renderer=new this.renderers[this.options.renderer](null,e)},_tileLoaded:function(e,t){e.data=t,this.drawTile(e)},_loadTile:function(e,t,n){var r=this,i=1<<n,s={x:(t.x%i+i)%i,y:t.y};this.provider.getTileData(s,n,function(t){r._tileLoaded(e,t)})},drawTile:function(e){var t=e.canvas;if(!e.data)return;t.width=t.width,this.renderer.setCanvas(t);var n=this.renderer.accumulate(e.data,this.key);this.renderer.renderTileAccum(n,0,0)},setKey:function(e){this.key=e,this.redraw()},setCartoCSS:function(e){if(!this.renderer)throw new Error("renderer is not valid");return this.renderer.setCartoCSS(e)}}),e.torque.GMapsTiledTorqueLayer=n,e.torque.GMapsTorqueLayer=t}(typeof exports=="undefined"?this:exports),typeof L!="undefined"&&(L.Mixin.TileLoader={_initTileLoader:function(){this._tiles={},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||t<this.options.minZoom)return;var r=new L.Point(Math.floor(e.min.x/n),Math.floor(e.min.y/n)),i=new L.Point(Math.floor(e.max.x/n),Math.floor(e.max.y/n)),s=new L.Bounds(r,i);this._addTilesFromCenterOut(s),this._removeOtherTiles(s)},_removeTiles:function(e){for(var t in this._tiles)this._removeTile(t)},_reloadTiles:function(){this._removeTiles(),this._updateTiles()},_removeOtherTiles:function(e){var t,n,r,i,s,o=this._map.getZoom();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),(o!==i||n<e.min.x||n>e.max.x||r<e.min.y||r>e.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._getNewTopLeftPoint(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(),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;s<u;s++){var a=t[s],f=this._tileKey(a);this._tilesLoading[f]=a,this.fire("tileAdded",a)}this.fire("tilesLoading")}}),typeof L!="undefined"&&(L.CanvasLayer=L.Class.extend({includes:[L.Mixin.Events,L.Mixin.TileLoader],options:{minZoom:0,maxZoom:28,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:L.Browser.mobile,updateWhenIdle:L.Browser.mobile,tileLoader:!1,zoomAnimation:!0},initialize:function(e){var t=this;e=e||{},this.render=this.render.bind(this),L.Util.setOptions(this,e),this._canvas=this._createCanvas(),this.options.zoomAnimation&&(this._backCanvas=this._createCanvas()),this._ctx=this._canvas.getContext("2d"),this.currentAnimationFrame=-1,this.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)},this.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||function(e){clearTimeout(e)}},_createCanvas:function(){var e;e=document.createElement("canvas"),e.style.position="absolute",e.style.top=0,e.style.left=0,e.style.pointerEvents="none",e.style.zIndex=this.options.zIndex||0;var t="leaflet-tile-container";return this.options.zoomAnimation&&(t+=" leaflet-zoom-animated"),e.setAttribute("class",t),e},onAdd:function(e){this._map=e;var t=this._map._panes.tilePane,n=L.DomUtil.create("div","leaflet-layer");n.appendChild(this._canvas),this.options.zoomAnimation&&(n.appendChild(this._backCanvas),this._backCanvas.style.display="none"),t.appendChild(n),this._container=n,e.dragging._draggable.on("predrag",function(){var t=e.dragging._draggable;L.DomUtil.setPosition(this._canvas,{x:-t._newPos.x,y:-t._newPos.y})},this),e.on({viewreset:this._reset},this),e.on("move",this.render,this),e.on("resize",this._reset,this),this.options.zoomAnimation&&e.on({zoomanim:this._animateZoom,zoomend:this._endZoomAnim,moveend:this._reset},this),this.options.tileLoader&&this._initTileLoader(),this._reset()},_animateZoom:function(e){this._animating||(this._animating=!0);var t=this._backCanvas;t.width=this._canvas.width,t.height=this._canvas.height;var n=this._canvas._leaflet_pos||{x:0,y:0};t.getContext("2d").drawImage(this._canvas,0,0),L.DomUtil.setPosition(t,L.DomUtil.getPosition(this._canvas)),this._canvas.style.display="none",t.style.display="block";var r=this._map,i=r.getZoomScale(e.zoom),s=r._latLngToNewLayerPoint(r.getCenter(),e.zoom,e.center),o=r._latLngToNewLayerPoint(e.center,e.zoom,e.center),u={x:s.x-o.x+n.x,y:s.y-o.y+n.y},a=t,f=L.DomUtil.TRANSFORM;setTimeout(function(){a.style[f]=L.DomUtil.getTranslateString(u)+" scale("+e.scale+") "},0)},_endZoomAnim:function(){this._animating=!1,this._canvas.style.display="block",this._backCanvas.style.display="none",this._backCanvas.style[L.DomUtil.TRANSFORM]=""},getCanvas:function(){return this._canvas},getAttribution:function(){return this.options.attribution},draw:function(){return this._reset()},onRemove:function(e){this._container.parentNode.removeChild(this._container),e.off({viewreset:this._reset,move:this._render,moveend:this._reset,resize:this._reset,zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this)},addTo:function(e){return e.addLayer(this),this},setOpacity:function(e){return this.options.opacity=e,this._updateOpacity(),this},setZIndex:function(e){this._canvas.style.zIndex=e,this.options.zoomAnimation&&(this._backCanvas.style.zIndex=e)},bringToFront:function(){return this},bringToBack:function(){return this},_reset:function(){var e=this._map.getSize();this._canvas.width=e.x,this._canvas.height=e.y;var t=L.DomUtil.getPosition(this._map.getPanes().mapPane);t&&L.DomUtil.setPosition(this._canvas,{x:-t.x,y:-t.y}),this.onResize(),this._render()},_updateOpacity:function(){},_render:function(){this.currentAnimationFrame>=0&&this.cancelAnimationFrame.call(window,this.currentAnimationFrame),this.currentAnimationFrame=this.requestAnimationFrame.call(window,this.render)},redraw:function(e){e?this.render():this._render()},onResize:function(){},render:function(){throw new Error("render function should be implemented")}})),typeof L!="undefined"&&(L.TorqueLayer=L.CanvasLayer.extend({providers:{sql_api:torque.providers.json,url_template:torque.providers.jsonarray,windshaft:torque.providers.windshaft},renderers:{point:torque.renderer.Point,pixel:torque.renderer.Rectangle},initialize:function(e){var t=this;if(!torque.isBrowserSupported())throw new Error("browser is not supported by torque");e.tileLoader=!0,this.key=0,this.prevRenderedKey=0,e.cartocss&&_.extend(e,torque.common.TorqueLayer.optionsFromCartoCSS(e.cartocss)),e.resolution=e.resolution||2,e.steps=e.steps||100,e.visible=e.visible===undefined?!0:e.visible,this.hidden=!e.visible,this.animator=new torque.Animator(function(e){var n=e|0;t.key!==n&&t.setKey(n,{direct:!0})},torque.clone(e)),this.play=this.animator.start.bind(this.animator),this.stop=this.animator.stop.bind(this.animator),this.pause=this.animator.pause.bind(this.animator),this.toggle=this.animator.toggle.bind(this.animator),this.setDuration=this.animator.duration.bind(this.animator),this.isRunning=this.animator.isRunning.bind(this.animator),L.CanvasLayer.prototype.initialize.call(this,e),this.options.renderer=this.options.renderer||"point",this.options.provider=this.options.provider||"windshaft",e.ready=function(){t.fire("change:bounds",{bounds:t.provider.getBounds()}),t.animator.steps(t.provider.getSteps()),t.animator.rescale(),t.fire("change:steps",{steps:t.provider.getSteps()}),t.setKey(t.key)},this.provider=new this.providers[this.options.provider](e),this.renderer=new this.renderers[this.options.renderer](this.getCanvas(),e),this.on("tileAdded",function(e){var n=this.provider.getTileData(e,e.zoom,function(n){if(e.zoom!==t._map.getZoom())return;t._tileLoaded(e,n),t._clearTileCaches(),n&&t.redraw()})},this)},_clearTileCaches:function(){var e,t;for(e in this._tiles)t=this._tiles[e],t&&t._tileCache&&(t._tileCache=null)},_clearCaches:function(){this.renderer&&this.renderer.clearSpriteCache(),this._clearTileCaches()},onAdd:function(e){e.on({zoomend:this._clearCaches,zoomstart:this._pauseOnZoom},this),e.on({zoomend:this._resumeOnZoom},this),L.CanvasLayer.prototype.onAdd.call(this,e)},onRemove:function(e){this._removeTileLoader(),e.off({zoomend:this._clearCaches,zoomstart:this._pauseOnZoom},this),e.off({zoomend:this._resumeOnZoom},this),L.CanvasLayer.prototype.onRemove.call(this,e)},_pauseOnZoom:function(){this.wasRunning=this.isRunning(),this.wasRunning&&this.pause()},_resumeOnZoom:function(){this.wasRunning&&this.play()},hide:function(){return this.hidden?this:(this.pause(),this.clear(),this.hidden=!0,this)},show:function(){return this.hidden?(this.hidden=!1,this.play(),this):this},setSQL:function(e){if(!this.provider||!this.provider.setSQL)throw new Error("this provider does not support SQL");return this.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(){return this.provider&&this.provider.getKeySpan()},clear:function(){var e=this.getCanvas();e.width=e.width},render:function(){if(this.hidden)return;var e,t,n,r=this.getCanvas();r.width=r.width;var i=r.getContext("2d");for(e in this._tiles)t=this._tiles[e],t&&(this.animator.isRunning()&&(t._tileCache=null),n=this.getTilePos(t.coord),i.setTransform(1,0,0,1,n.x,n.y),t._tileCache?this.renderer._ctx.drawImage(t._tileCache,0,0):this.renderer.renderTile(t,this.key));if(!this.animator.isRunning()&&this.key===this.prevRenderedKey){var s=this.renderer.TILE_SIZE;for(e in this._tiles){t=this._tiles[e];if(t&&!t._tileCache){var o=t._tileCache=document.createElement("canvas");o.width=o.height=s,n=this.getTilePos(t.coord),o.getContext("2d").drawImage(this.getCanvas(),n.x,n.y,s,s,0,0,s,s)}}}this.prevRenderedKey=this.key},setKey:function(e,t){this.key=e,this.animator.step(e),this._clearTileCaches(),this.redraw(t&&t.direct),this.fire("change:time",{time:this.getTime(),step:this.key})},setStep:function(e){if(e===undefined||e.length!==undefined)throw new Error("setTime only accept scalars");this.setKey(e)},stepToTime:function(e){var t=this.provider.getKeySpan(),n=t.start+(t.end-t.start)*(e/this.provider.getSteps());return new Date(n)},getStep:function(){return this.key},getTime:function(){return this.stepToTime(this.key)},getTimeSpan:function(){var e=this.provider.getKeySpan()},setCartoCSS:function(e){if(!this.renderer)throw new Error("renderer is not valid");var t=(new carto.RendererJS).render(e);this.renderer.setShader(t);var n=torque.common.TorqueLayer.optionsFromLayer(t.findLayer({name:"Map"}));return this.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){var t=[];for(var n in this._tiles){var r=this._tiles[n];t=t.concat(this.renderer.getActivePointsBBox(r,e))}return t},getValueForPos:function(e,t,n){n=n===undefined?this.key: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<this.renderer.TILE_SIZE&&a<=this.renderer.TILE_SIZE&&(o=this.renderer.getValueFor(i,n,u,a));if(o!==null)return o}return null}})); |