From 1c6d3533b6cbd5d42b5d6fb8ec740d6e5d9df49f Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 13 Aug 2015 13:09:49 -0700 Subject: [PATCH] Remove support for pre-v6 styles --- README.md | 4 +- index.js | 4 - lib/migrate.js | 21 - migrations/v3.js | 159 ------ migrations/v4-bonus.js | 141 ------ migrations/v4.js | 130 ----- migrations/v5.js | 53 -- migrations/v6-filter.js | 79 --- migrations/v6.js | 86 ---- reference/v2.json | 571 ---------------------- reference/v3.json | 894 ---------------------------------- reference/v4.json | 891 ---------------------------------- reference/v5.json | 912 ----------------------------------- test/migrate.js | 2 +- test/migrations/v6-filter.js | 86 ---- test/migrations/v6.js | 96 ---- test/spec.js | 2 +- 17 files changed, 4 insertions(+), 4127 deletions(-) delete mode 100644 migrations/v3.js delete mode 100644 migrations/v4-bonus.js delete mode 100644 migrations/v4.js delete mode 100644 migrations/v5.js delete mode 100644 migrations/v6-filter.js delete mode 100644 migrations/v6.js delete mode 100644 reference/v2.json delete mode 100644 reference/v3.json delete mode 100644 reference/v4.json delete mode 100644 reference/v5.json delete mode 100644 test/migrations/v6-filter.js delete mode 100644 test/migrations/v6.js diff --git a/README.md b/README.md index bbbbbe6..fff5925 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,10 @@ Will validate the given style JSON and print errors to stdout. Provide a ### Migrations This repo contains scripts for migrating GL styles of any version to the latest version -(currently v5). Migrate a style like this: +(currently v8). Migrate a style like this: ```bash -$ gl-style-migrate bright-v0.json > bright-v5.json +$ gl-style-migrate bright-v7.json > bright-v8.json ``` To migrate a file in place, you can use the `sponge` utility from the `moreutils` package: diff --git a/index.js b/index.js index 179c9da..da2df44 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,3 @@ -exports.v2 = require('./reference/v2.json'); -exports.v3 = require('./reference/v3.json'); -exports.v4 = require('./reference/v4.json'); -exports.v5 = require('./reference/v5.json'); exports.v6 = require('./reference/v6.json'); exports.v7 = require('./reference/v7.json'); exports.v8 = require('./reference/v8.json'); diff --git a/lib/migrate.js b/lib/migrate.js index 8db12dc..dc264a2 100644 --- a/lib/migrate.js +++ b/lib/migrate.js @@ -15,27 +15,6 @@ module.exports = function(style) { var migrated = false; - if (style.version === 2) { - style = require('../migrations/v3')(style); - migrated = true; - } - - if (style.version === 3) { - style = require('../migrations/v4')(style); - style = require('../migrations/v4-bonus')(style); - migrated = true; - } - - if (style.version === 4) { - style = require('../migrations/v5')(style); - migrated = true; - } - - if (style.version === 5) { - style = require('../migrations/v6')(style); - migrated = true; - } - if (style.version === 6) { style = require('../migrations/v7')(style); migrated = true; diff --git a/migrations/v3.js b/migrations/v3.js deleted file mode 100644 index 813866c..0000000 --- a/migrations/v3.js +++ /dev/null @@ -1,159 +0,0 @@ -'use strict'; - -var ref = require('../reference/v3'); - -module.exports = function upgrade(v2) { - return converter(v2); -}; - -function converter(v2) { - var v3 = { - version: 3 - }; - - if (v2.sprite) { - v3.sprite = v2.sprite; - } - - if (v2.constants) { - v3.constants = {}; - for (var k in v2.constants) { - v3.constants[(k.charAt(0) !== '@' ? '@' : '') + k] = v2.constants[k]; - } - } - - if (v2.sources) { - v3.sources = v2.sources; - } - - var memo = {}; - - v3.layers = v2.layers.map(function(layer) { - return convertLayer(memo, layer, v2.buckets || {}, v2.styles || {}, v2.constants || {}); - }); - - return v3; -} - -function convertLayer(memo, v2, buckets, styles, constants) { - var j, k, val, known; - var v3 = {}; - v3.id = v2.id; - - // This is a composite layer. Recurse. - if (v2.layers) { - v3.layers = v2.layers.map(function(layer) { - return convertLayer(memo, layer, buckets, styles, constants); - }); - // This layer's bucket has not been established yet. Do so. - } else if (v2.bucket && !memo[v2.bucket]) { - memo[v2.bucket] = v2.id; - - var bucket = buckets[v2.bucket]; - if (!bucket) throw new Error('bucket not found for layer ' + v2.id); - - // Migrate bucket.filter. - if (bucket.filter) for (k in bucket.filter) { - if (k === 'source') { - v3.source = bucket.filter[k]; - } else if (k === 'layer') { - v3['source-layer'] = bucket.filter[k]; - } else if (k === 'feature_type') { - v3.filter = v3.filter || {}; - v3.filter.$type = bucket.filter[k] === 'fill' ? 'polygon' : bucket.filter[k]; - } else { - v3.filter = v3.filter || {}; - v3.filter[k] = bucket.filter[k]; - } - } - // Migrate bucket properties. - for (k in bucket) { - if (k === 'filter') continue; - val = bucket[k]; - v3.render = v3.render || {}; - - // specific migrations. - if (k === 'point-size') { - k = 'icon-size'; - v3.render[k] = Array.isArray(val) ? val[0] : val; - continue; - } - - if (/^(fill|line|point|text|raster|composite)$/.test(k)) { - v3.render.type = k === 'point' ? 'icon' : k; - continue; - } - - k = k.replace('point-', 'icon-'); - known = false; - for (j = 0; j < ref.render.length; j++) { - known = known || (!!ref[ref.render[j]][k]); - } - if (!known) { - console.warn('Skipping unknown render property %s', k); - continue; - } - - v3.render[k] = val; - } - } else if (v2.bucket) { - v3.ref = memo[v2.bucket]; - if (v3.ref === v3.id) throw ('Two layers with the same id: ' + v3.id); - } - - var background = false; - if (v3.id === 'background') { - v3.render = { type: 'background' }; - background = true; - } - - for (var className in styles) { - if (!styles[className][v2.id]) continue; - var styleName = className === 'default' ? 'style' : 'style.' + className; - for (k in styles[className][v2.id]) { - val = styles[className][v2.id][k]; - val = typeof constants[val] !== 'undefined' ? '@' + val : val; - v3[styleName] = v3[styleName] || {}; - - // specific migrations. - if (k === 'point-alignment') { - k = 'icon-rotate-anchor'; - v3[styleName][k] = val !== 'screen' ? 'map' : 'viewport'; - continue; - } - if (k === 'stroke-color') { - k = 'fill-outline-color'; - v3[styleName][k] = val; - continue; - } - // composite styles - if (k === 'opacity') { - k = 'composite-opacity'; - v3.render = { type: 'composite' }; - v3[styleName][k] = val; - continue; - } - if (k === 'transition-opacity') { - k = 'transition-composite-opacity'; - v3.render = { type: 'composite' }; - v3[styleName][k] = val; - continue; - } - - k = k.replace('point-', 'icon-'); - if (background) k = k.replace('fill-', 'background-'); - known = false; - for (j = 0; j < ref['class'].length; j++) { - known = known || (!!ref[ref['class'][j]][k]); - } - if (!known) { - console.warn('Skipping unknown class property %s', k); - continue; - } - v3[styleName][k] = val; - } - } - - return v3; -} - diff --git a/migrations/v4-bonus.js b/migrations/v4-bonus.js deleted file mode 100644 index 1ad74f5..0000000 --- a/migrations/v4-bonus.js +++ /dev/null @@ -1,141 +0,0 @@ -'use strict'; - -var vc; - -module.exports = function(v4) { - v4.version = 4; - vc = v4.constants; - convertConstants(vc); - rmTileSize(v4.sources); - v4.layers.forEach(convertLayer); - return v4; -}; - -function rmTileSize(sources) { - for (var source in sources) { - if (sources[source].type != 'raster' && sources[source].tileSize) delete sources[source].tileSize; - } -} - -function convertLayer(layer) { - // convert linear/exponential functions to stop functions - // decrement zoom level of functions by 1 for map tileSize (512) change - for (var classname in layer) { - if (layer[classname]['text-max-angle']) { - layer[classname]['text-max-angle'] = Number((layer[classname]['text-max-angle'] * 180 / Math.PI).toFixed(2)); - } - if (classname.indexOf('style') === -1) continue; - var style = layer[classname]; - for (var propname in style) { - if (Array.isArray(style[propname])) { - for (var prop in style[propname]) { - if (!style[propname][prop].fn) continue; - style[propname][prop] = fnBucket(style[propname][prop]); - } - } - if (!style[propname].fn) continue; - style[propname] = fnBucket(style[propname]); - } - } - - if (layer.layers) layer.layers.forEach(convertLayer); - -} - -function convertConstants(constants) { - for (var constant in constants) { - if (constants[constant].fn) { - constants[constant] = fnBucket(constants[constant]); - } - - if (Array.isArray(constants[constant])) { - for (var item in constants[constant]) { - if (constants[constant][item].fn) { - constants[constant][item] = fnBucket(constants[constant][item]); - } - } - } - } -} - -function fnBucket(oldfn) { - var newfn; - if (oldfn.fn === 'stops') { - newfn = { stops: oldfn.stops }; - } else if (oldfn.fn === 'linear' || oldfn.fn === 'exponential') { - newfn = migrateFn(oldfn); - } - // Decrement zoom levels by 1. - newfn.stops = newfn.stops.map(deczoom); - return newfn; -} - -function deczoom(pair) { - return [Math.max(0, pair[0] - 1), pair[1]]; -} - -function migrateFn(params) { - var newparams = {}; - var minZoom = 0; - var maxZoom = 20; - var fn; - if (params.fn === 'exponential') { - fn = exponential(params); - if (params.base) newparams.base = params.base; - if (params.min !== undefined) minZoom = reverseExponential(params, Math.max(params.min, params.val)); - if (params.max !== undefined) maxZoom = reverseExponential(params, params.max); - newparams.stops = [ - [minZoom, fn(minZoom)], - [maxZoom, fn(maxZoom)] - ]; - } else if (params.fn === 'linear') { - fn = linear(params); - newparams.base = 1.01; - if (params.min !== undefined) minZoom = reverseLinear(params, params.min); - if (params.max !== undefined) maxZoom = reverseLinear(params, params.max); - newparams.stops = [ - [minZoom, fn(minZoom)], - [maxZoom, fn(maxZoom)] - ]; - } - - return newparams; -} - -function reverseExponential(params, value) { - var z_base = +params.z || 0, - val = +params.val || 0, - slope = +params.slope || 0, - base = +params.base || 1.75; - return Math.log(((value - val) || 0.01) / slope) / Math.log(base) + z_base; -} - -function reverseLinear(params, value) { - var z_base = +params.z || 0, - val = +params.val || 0, - slope = +params.slope || 0; - return (value - val) / slope + z_base; -} - -function linear(params) { - var z_base = +params.z || 0, - val = +params.val || 0, - slope = +params.slope || 0, - min = +params.min || 0, - max = +params.max || Infinity; - return function(z) { - return Math.min(Math.max(min, val + (z - z_base) * slope), max); - }; -} - -function exponential(params) { - var z_base = +params.z || 0, - val = +params.val || 0, - slope = +params.slope || 0, - min = +params.min || 0, - max = +params.max || Infinity, - base = +params.base || 1.75; - return function(z) { - return Math.min(Math.max(min, val + Math.pow(base, (z - z_base)) * slope), max); - }; -} diff --git a/migrations/v4.js b/migrations/v4.js deleted file mode 100644 index dd7d67f..0000000 --- a/migrations/v4.js +++ /dev/null @@ -1,130 +0,0 @@ -'use strict'; - -//var ref = require('../lib/reference')('v4'); - -var vc; - -module.exports = function(v3) { - v3.version = 4; - vc = v3.constants; - for (var id in v3.sources) { - var source = v3.sources[id]; - if (source.glyphs) { - v3.glyphs = source.glyphs; - delete source.glyphs; - } - } - v3.layers.forEach(convertLayer); - return v3; -}; - -var newTypes = { - point: 'Point', - line: 'LineString', - polygon: 'Polygon' -}; - -function convertLayer(layer) { - var render = layer.render; - - if (!render) return; - - layer.type = render.type; - delete render.type; - - - if (Object.keys(render).length === 0) { // was just type - delete layer.render; - } - - if (layer.filter && layer.filter.$type) { - layer.filter.$type = newTypes[layer.filter.$type]; - } - - if (layer.filter && layer.filter['!' || '|' || '&' || '^'] && layer.filter['!' || '|' || '&' || '^'].$type) { - layer.filter['!' || '|' || '&' || '^'].$type = newTypes[layer.filter['!' || '|' || '&' || '^'].$type]; - } - - if (layer.type === 'text' || layer.type === 'icon') { - layer.type = 'symbol'; - - var convertHalo = function(haloWidth, textSize) { - return Number(((6 - haloWidth * 8) * textSize / 24).toFixed(2)); - }; - - // convert text-halo-width to pixels - for (var classname in layer) { - if (classname.indexOf('style') === 0) { - var style = layer[classname]; - if (style['text-halo-width']) { - if (typeof style['text-halo-width'] == 'string' && style['text-halo-width'].indexOf('@') != -1) { - style['text-halo-width'] = vc[style['text-halo-width']]; - } - // handle 3 cases: text-size as constant, text-size as #, no text-size but max-text-size - var textSize = (typeof style['text-size'] == 'string' && - style['text-size'].indexOf('@') != -1) ? - vc[style['text-size']] : - (style['text-size'] ? - style['text-size'] : - layer.render['text-max-size']); - - // handle text-size numbers and functions - if (typeof textSize == 'number') { - style['text-halo-width'] = convertHalo(style['text-halo-width'], textSize); - } else if (textSize && textSize.fn && textSize.fn == 'stops') { - var stops = []; - for (var stop in textSize.stops) { - stops.push( - [textSize.stops[stop][0], - convertHalo(style['text-halo-width'], textSize.stops[stop][1])] - ); - } - style['text-halo-width'] = { - "fn": "stops", - "stops": stops - }; - } else if (textSize && textSize.fn && textSize.fn == ('exponential' || 'linear')) { - var val; var max; var min; - if (textSize.val) val = convertHalo(style['text-halo-width'], textSize.val); - if (textSize.max) max = convertHalo(style['text-halo-width'], textSize.max); - if (textSize.min) min = convertHalo(style['text-halo-width'], textSize.min); - style['text-halo-width'] = textSize; - style['text-halo-width'].val = val; - style['text-halo-width'].max = max; - style['text-halo-width'].min = min; - } - } - } - } - - if (!layer.render) return; - - rename(render, 'icon-spacing', 'symbol-min-distance'); - rename(render, 'text-min-distance', 'symbol-min-distance'); - rename(render, 'text-alignment', 'text-horizontal-align'); - rename(render, 'text-vertical-alignment', 'text-vertical-align'); - - if (layer.style && layer.style['icon-rotate-anchor']) { - render['symbol-rotation-alignment'] = layer.style['icon-rotate-anchor']; - delete layer.style['icon-rotate-anchor']; - } - - if (render['text-path'] === 'curve') { - render['symbol-placement'] = 'line'; - } - - if (render['icon-size']) { - delete render['icon-size']; - } - - delete render['text-path']; - } - if (layer.layers) layer.layers.forEach(convertLayer); -} - -function rename(render, from, to) { - if (render[from]) { - render[to] = render[from]; - delete render[from]; - } -} diff --git a/migrations/v5.js b/migrations/v5.js deleted file mode 100644 index 8942b73..0000000 --- a/migrations/v5.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -// Should be idempotent. - -module.exports = function(style) { - var k; - - style.version = 5; - - var sources = style.sources; - for (k in sources) { - var source = sources[k]; - rename(source, 'minZoom', 'minzoom'); - rename(source, 'maxZoom', 'maxzoom'); - - if (source.type !== "video" && source.url && !source.url.match(/^mapbox:\/\//)) { - source.tiles = [source.url]; - delete source.url; - } - } - - if (style.glyphs === 'https://mapbox.s3.amazonaws.com/gl-glyphs-256/{fontstack}/{range}.pbf') { - style.glyphs = 'mapbox://fontstack/{fontstack}/{range}.pbf'; - } - - var layers = style.layers; - for (k in layers) { - var layer = layers[k]; - - for (var classname in layer) { - if (classname.indexOf('style') === 0) { - var klass = layer[classname]; - rename(klass, 'raster-fade', 'raster-fade-duration'); - - for (var p in klass) { - var match = p.match(/^transition-(.*)$/); - if (match) { - rename(klass, match[0], match[1] + '-transition'); - } - } - } - } - } - - return style; -}; - -function rename(o, from, to) { - if (from in o) { - o[to] = o[from]; - delete o[from]; - } -} diff --git a/migrations/v6-filter.js b/migrations/v6-filter.js deleted file mode 100644 index 8c57556..0000000 --- a/migrations/v6-filter.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -function migrate(key, value) { - switch (key) { - case '&&': - return ['all'].concat(value.map(module.exports)); - case '||': - return ['any'].concat(value.map(module.exports)); - case '!': - return invert(module.exports(value)); - case '&': - return module.exports(value); - case '|': - var f = module.exports(value); - if (f[0] === 'all') { - f[0] = 'any'; - return f; - } else { - return ['any', module.exports(value)]; - } - break; - case '^': - throw new Error('can\'t migrate ^ (XOR) filters'); - default: - if (typeof value !== 'object') { - return ['==', key, value]; - } else if (Array.isArray(value)) { - return ['in', key].concat(value); - } else if (Object.keys(value).length > 1) { - throw new Error('can\'t migrate complex filter ' + JSON.stringify(value)); - } else { - var k = Object.keys(value)[0], - v = value[k]; - if (k === 'in' || k === '!in') { - return [k, key].concat(v); - } else if (Array.isArray(v)) { - return ['all'].concat(v.map(function (v) { - return [k, key, v]; - })); - } else { - return [k, key, v]; - } - } - } -} - -function invert(filter6) { - if (filter6[0] === 'all') { - return ['any'].concat(filter6.slice(1).map(invert)); - } else { - filter6[0] = { - '==': '!=', - '!=': '==', - '<': '>=', - '<=': '>', - '>': '<=', - '>=': '<', - 'in': '!in', - '!in': 'in', - 'any': 'none', - 'none': 'any' - }[filter6[0]]; - return filter6; - } -} - -module.exports = function(filter5) { - var filters6 = []; - - for (var key in filter5) { - filters6.push(migrate(key, filter5[key])); - } - - if (filters6.length === 1) - return filters6[0]; - - filters6.unshift('all'); - return filters6; -}; diff --git a/migrations/v6.js b/migrations/v6.js deleted file mode 100644 index f429778..0000000 --- a/migrations/v6.js +++ /dev/null @@ -1,86 +0,0 @@ -'use strict'; - -// Should be idempotent. - -var ref = require('../reference/v6'); - -function eachLayer(layer, callback) { - for (var k in layer.layers) { - callback(layer.layers[k]); - eachLayer(layer.layers[k], callback); - } -} - -function eachPaint(layer, callback) { - for (var k in layer) { - if (k.indexOf('paint') === 0) { - callback(layer[k], k); - } - } -} - -module.exports = function(style) { - style.version = 6; - - eachLayer(style, function (layer) { - rename(layer, 'render', 'layout'); - - for (var k in layer) { - if (k.indexOf('style') === 0) { - rename(layer, k, k.replace(/^style/, 'paint')); - } - } - - eachPaint(layer, function(paint) { - if (paint['line-offset']) { - var w = paint['line-width'] ? paint['line-width'] : ref.class_line['line-width'].default; - if (typeof w === 'string') w = style.constants[w]; - - if (w && !w.stops) { - if (typeof paint['line-offset'] === 'number') { - paint['line-offset'] = paint['line-offset'] - w; - } else if (paint['line-offset'].stops) { - var stops = paint['line-offset'].stops; - for (var s in paint['line-offset'].stops) { - stops[s][1] = stops[s][1] - w; - } - } - } - } - rename(paint, 'line-offset', 'line-gap-width'); - }); - - if (layer.layout) { - var h = layer.layout['text-horizontal-align'], - v = layer.layout['text-vertical-align']; - - if (h === 'center') h = undefined; - if (v === 'center') v = undefined; - - delete layer.layout['text-horizontal-align']; - delete layer.layout['text-vertical-align']; - - if (h && v) { - layer.layout['text-anchor'] = v + '-' + h; - } else if (h || v) { - layer.layout['text-anchor'] = h || v; - } - } - - rename(layer, 'min-zoom', 'minzoom'); - rename(layer, 'max-zoom', 'maxzoom'); - - if (layer.filter && !Array.isArray(layer.filter)) { - layer.filter = require('./v6-filter')(layer.filter); - } - }); - - return style; -}; - -function rename(o, from, to) { - if (from in o) { - o[to] = o[from]; - delete o[from]; - } -} diff --git a/reference/v2.json b/reference/v2.json deleted file mode 100644 index d828d36..0000000 --- a/reference/v2.json +++ /dev/null @@ -1,571 +0,0 @@ -{ - "$version": 2, - "$root": { - "version": { - "type": "enum", - "values": [ - 2 - ], - "doc": "Stylesheet version number. Must be 2." - }, - "constants": { - "type": "constants", - "doc": "A list of constants." - }, - "sources": { - "type": "sources", - "doc": "Source specifications for layers to pull data from" - }, - "layers": { - "required": true, - "type": "array", - "value": "layer", - "doc": "A list of layers." - }, - "buckets": { - "required": true, - "type": "buckets" - }, - "styles": { - "required": true, - "type": "styles" - }, - "sprite": { - "type": "sprite" - } - }, - "sources": { - "*": { - "type": "source" - } - }, - "source": { - "type": { - "required": true, - "type": "enum", - "values": [ - "vector", - "raster", - "video" - ] - }, - "url": { - "required": true, - "type": "string" - }, - "glyphs": { - "type": "string" - }, - "tileSize": { - "type": "number" - } - }, - "styles": { - "*": { - "type": "style_class" - } - }, - "style_class": { - "*": { - "type": "style" - } - }, - "buckets": { - "*": { - "type": "bucket" - } - }, - "bucket_filter": { - "feature_type": { - "type": "enum", - "values": [ - "point", - "line", - "fill" - ], - "doc": "Geometry type that features must match" - }, - "source": { - "type": "string", - "doc": "ID of the vector or raster tile source to be used" - }, - "layer": { - "type": "string", - "doc": "Layer to use from a vector tile source" - }, - "*": { - "type": "*", - "doc": "One or more filter expressions to apply to feature properties" - } - }, - "bucket": { - "filter": { - "type": "bucket_filter", - "doc": "A bucket filter object defining data to be styled" - }, - "fill": { - "type": "boolean", - "default": false, - "doc": "Set for fill buckets" - }, - "line": { - "type": "boolean", - "default": false, - "doc": "Set for line buckets" - }, - "line-cap": { - "type": "enum", - "values": [ - "butt", - "round", - "square" - ], - "default": "butt", - "doc": "The display of line endings" - }, - "line-join": { - "type": "enum", - "values": [ - "bevel", - "round", - "miter" - ], - "default": "miter", - "doc": "The behavior of lines when joining" - }, - "line-miter-limit": { - "type": "number", - "default": 2, - "doc": "Used to automatically convert miter joins to bevel joins for sharp angles" - }, - "line-round-limit": { - "type": "number", - "default": 1, - "doc": "Used to automatically convert round joins to miter joins for shallow angles" - }, - "text": { - "type": "boolean", - "default": false, - "doc": "Set for text buckets" - }, - "text-field": { - "type": "expression", - "default": "", - "doc": "Value to use for a text label. Feature properties are specified using tokens like {{field_name}}" - }, - "text-path": { - "type": "enum", - "values": [ - "curve", - "horizontal" - ], - "default": "@TODO", - "doc": "" - }, - "text-font": { - "type": "string", - "default": "", - "doc": "Fontstack to use for displaying text" - }, - "text-max-size": { - "type": "number", - "doc": "Largest size text will be displayed" - }, - "text-max-width": { - "type": "number", - "doc": "Largest line width for text wrapping (em)" - }, - "text-line-height": { - "type": "number", - "default": 1.2, - "doc": "Text leading value for multi-line text (em)" - }, - "text-letter-spacing": { - "type": "number", - "default": 0, - "doc": "Text kerning value (em)" - }, - "text-alignment": { - "type": "enum", - "values": [ - "left", - "right", - "center" - ], - "default": "center", - "doc": "Text alignment options" - }, - "text-max-angle": { - "type": "number", - "doc": "@TODO" - }, - "text-min-distance": { - "type": "number", - "default": 250, - "doc": "Minimum distance between two values (px)" - }, - "text-rotate": { - "type": "number", - "default": 0 - }, - "text-slant": { - "type": "number", - "doc": "@TODO" - }, - "text-padding": { - "type": "number", - "default": 2, - "doc": "Padding value around text bounding box to avoid label collisions (px)" - }, - "point": { - "type": "boolean", - "default": false, - "doc": "Set for point buckets" - }, - "point-image": { - "type": "expression", - "default": "", - "doc": "Name of image in sprite to use for icons. Feature properties can be used as tokens like {{field_name}}" - }, - "point-size": { - "type": "array", - "value": "number", - "default": [ - 12, - 12 - ], - "doc": "Width and height of image points" - }, - "point-radius": { - "type": "number", - "doc": "Radius of circle points" - }, - "point-spacing": { - "type": "number", - "default": 0, - "doc": "" - }, - "point-padding": { - "type": "number", - "default": 2, - "doc": "" - } - }, - "layer": [ - { - "id": { - "type": "string", - "default": "", - "doc": "Unique layer name. Must match the name of a single style to be applied to the layer" - }, - "bucket": { - "type": "string", - "default": "", - "doc": "Name of the bucket that layer styles will be applied to" - } - }, - { - "id": { - "type": "string", - "default": "", - "doc": "Composite layer name. Must match the name of a single style to be applied to the layer" - }, - "layers": { - "type": "array", - "value": "layer", - "doc": "A list of layers that should be composited together for this group" - } - } - ], - "expression": { - "type": "string" - }, - "constants": { - "*": { - "type": "*" - } - }, - "transition": { - "duration": { - "type": "number" - }, - "delay": { - "type": "number" - } - }, - "function": { - "fn": { - "type": "enum", - "values": [ - "stops", - "linear", - "exponential" - ] - }, - "stops": { - "type": "array", - "value": "array" - }, - "z": { - "type": "number" - }, - "val": { - "type": "number" - }, - "base": { - "type": "number" - }, - "slope": { - "type": "number" - }, - "min": { - "type": "number" - }, - "max": { - "type": "number" - } - }, - "style": { - "hidden": { - "type": "boolean", - "function": true - }, - "opacity": { - "type": "number", - "function": true, - "transition": true, - "default": 1 - }, - "fill-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "line-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "text-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "point-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "fill-color": { - "type": "color", - "transition": true, - "required": true, - "function": true, - "default": [ - 0, - 0, - 0, - 1 - ] - }, - "line-color": { - "type": "color", - "transition": true, - "required": true, - "function": true, - "default": [ - 0, - 0, - 0, - 1 - ] - }, - "stroke-color": { - "transition": true, - "type": "color", - "function": true - }, - "point-color": { - "type": "color", - "required": true, - "function": true, - "default": [ - 1, - 1, - 1, - 1 - ] - }, - "text-color": { - "type": "color", - "transition": true, - "required": true, - "function": true, - "default": [ - 0, - 0, - 0, - 1 - ] - }, - "text-halo-color": { - "transition": true, - "function": true, - "type": "color" - }, - "fill-antialias": { - "type": "boolean", - "default": true - }, - "point-antialias": { - "type": "boolean" - }, - "line-antialias": { - "type": "boolean", - "default": true - }, - "line-width": { - "transition": true, - "type": "number", - "function": true, - "default": 1 - }, - "line-offset": { - "type": "number", - "transition": true, - "function": true, - "default": 0 - }, - "line-blur": { - "type": "number", - "transition": true, - "function": true, - "default": 1 - }, - "point-blur": { - "type": "number", - "function": true, - "default": 1.5 - }, - "point-rotate": { - "type": "number", - "function": true - }, - "text-size": { - "type": "number", - "function": true - }, - "text-halo-width": { - "type": "number", - "function": true, - "default": 0.25 - }, - "text-halo-blur": { - "type": "number", - "function": true, - "default": 1 - }, - "line-dasharray": { - "type": "array", - "value": "number", - "transition": true, - "default": [ - 1, - -1 - ] - }, - "line-translate": { - "type": "array", - "value": "number", - "default": [ - 0, - 0 - ] - }, - "fill-translate": { - "type": "array", - "value": "number", - "default": [ - 0, - 0 - ] - }, - "text-translate": { - "type": "array", - "value": "number", - "default": [ - 0, - 0 - ] - }, - "point-translate": { - "type": "array", - "value": "number", - "default": [ - 0, - 0 - ] - }, - "point-image": { - "type": "image" - }, - "fill-image": { - "type": "image" - }, - "line-image": { - "type": "image", - "default": "", - "doc": "Name of image in sprite to use for drawing image lines" - }, - "point-invert": { - "type": "boolean" - }, - "point-radius": { - "type": "number", - "default": 4 - }, - "point-alignment": { - "type": "enum", - "values": [ - "screen", - "line" - ] - }, - "raster-spin": { - "type": "number", - "default": 0 - }, - "raster-brightness-low": { - "type": "number", - "transition": true, - "default": 0 - }, - "raster-brightness-high": { - "type": "number", - "transition": true, - "default": 1 - }, - "raster-saturation": { - "type": "number", - "transition": true, - "default": 0 - }, - "raster-contrast": { - "type": "number", - "default": 0 - }, - "raster-fade": { - "type": "number" - } - }, - "sprite": { - "type": "string" - }, - "image": { - "type": "string" - } -} \ No newline at end of file diff --git a/reference/v3.json b/reference/v3.json deleted file mode 100644 index 99f9a4c..0000000 --- a/reference/v3.json +++ /dev/null @@ -1,894 +0,0 @@ -{ - "$version": 3, - "$root": { - "version": { - "required": true, - "type": "enum", - "values": [ - 3 - ], - "doc": "Stylesheet version number. Must be 3." - }, - "constants": { - "type": "constants", - "doc": "An object of constants to be referenced in layers." - }, - "sources": { - "required": true, - "type": "sources", - "doc": "Data source specifications for layers to pull from." - }, - "layers": { - "required": true, - "type": "array", - "value": "layer", - "doc": "A an array of layers. The order of layers coincides with the order they will be drawn." - }, - "sprite": { - "type": "sprite", - "doc": "Sprite definition." - }, - "glyphs": { - "type": "string", - "doc": "A URL template for loading signed-distance-field glyph sets in PBF format. Valid tokens are {{fontstack}} and {{range}}." - } - }, - "sprite": { - "type": "string", - "doc": "A base URL for retrieving the sprite image and metadata. The extensions `.png`, `.json` and scale factor `@2x.png` will be automatically appended." - }, - "constants": { - "*": { - "type": "*", - "doc": "A constant that will be replaced verbatim in the referencing place. This can be anything, including objects and arrays. All variable names must be prefixed with an `@` symbol." - } - }, - "sources": { - "*": { - "type": "source" - } - }, - "source": { - "type": { - "required": true, - "type": "enum", - "values": [ - "vector", - "raster", - "geojson", - "video" - ], - "doc": "The data type of the source." - }, - "url": { - "required": true, - "type": "string", - "doc": "A URL, or URL template to retrive the source data." - }, - "tileSize": { - "type": "number", - "default": 512 - }, - "minZoom": { - "type": "number", - "default": 0 - }, - "maxZoom": { - "type": "number", - "default": 22 - }, - "*": { - "type": "*", - "doc": "Other keys to configure the data source." - } - }, - "layer": { - "id": { - "type": "string", - "doc": "Unique layer name." - }, - "ref": { - "type": "string", - "doc": "References another layer to copy `source`, `source_layer`, `filter`, and `render` properties from. This allows the layers to share processing and be more efficient." - }, - "source": { - "type": "string", - "doc": "Name of a source description to be used for this layer. Required if this is not a composite layer." - }, - "source-layer": { - "type": "string", - "doc": "Layer to use from a vector tile source. Required if this is not a composite layer, and if the source supports multiple layers." - }, - "render": { - "type": "render", - "doc": "Symbolizer type that should be used to visualize this layer. If unspecified or null, this layer is not treated as a symbolizer and only exists to have properties inherited to other layers using ref." - }, - "filter": { - "type": "filter", - "doc": "Array or object of filters or expressions." - }, - "layers": { - "type": "array", - "value": "layer", - "doc": "If 'type' is 'composite', the child layers are composited together onto the previous level layer level." - }, - "rasterize": { - "type": "rasterize" - }, - "style": { - "type": "class", - "doc": "Default style properties for this layer." - }, - "style.*": { - "type": "class", - "doc": "Override style properties for this layer. The class name is the part after the first dot." - } - }, - "rasterize": { - "enabled": { - "type": "boolean", - "function": true, - "default": false - }, - "buffer": { - "type": "number", - "function": true, - "default": 0.03125 - }, - "size": { - "type": "number", - "function": true, - "default": 256 - }, - "blur": { - "type": "number", - "function": true, - "default": 0 - } - }, - "render": [ - "render_fill", - "render_line", - "render_icon", - "render_text", - "render_composite", - "render_raster" - ], - "render_fill": { - "type": { - "type": "enum", - "values": [ - "fill" - ] - }, - "fill-winding": { - "type": "enum", - "values": [ - "non-zero", - "even-odd" - ], - "default": "non-zero" - } - }, - "render_line": { - "type": { - "type": "enum", - "values": [ - "line" - ] - }, - "line-cap": { - "type": "enum", - "values": [ - "butt", - "round", - "square" - ], - "default": "butt", - "doc": "The display of line endings." - }, - "line-join": { - "type": "enum", - "values": [ - "bevel", - "round", - "miter" - ], - "default": "miter", - "doc": "The display of lines when joining." - }, - "line-miter-limit": { - "type": "number", - "default": 2, - "doc": "Used to automatically convert miter joins to bevel joins for sharp angles." - }, - "line-round-limit": { - "type": "number", - "default": 1, - "doc": "Used to automatically convert round joins to miter joins for shallow angles." - } - }, - "render_icon": { - "type": { - "type": "enum", - "values": [ - "icon" - ] - }, - "icon-size": { - "type": "number", - "default": 16 - }, - "icon-image": { - "type": "string", - "doc": "A string with {{tokens}} replaced, referencing the data property to pull from." - }, - "icon-spacing": { - "type": "number", - "default": 0, - "doc": "" - }, - "icon-padding": { - "type": "number", - "default": 2, - "doc": "Padding value around icon bounding box to avoid icon collisions (px)." - }, - "icon-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true - }, - "icon-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "map" - }, - "icon-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the icon will be visible even if it collides with other icons and labels." - }, - "icon-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, the icon won't affect placement of other icons and labels." - } - }, - "render_text": { - "type": { - "type": "enum", - "values": [ - "text" - ] - }, - "text-field": { - "type": "string", - "default": "", - "doc": "Value to use for a text label. Feature properties are specified using tokens like {{field_name}}." - }, - "text-path": { - "type": "enum", - "values": [ - "horizontal", - "curve" - ], - "default": "horizontal", - "doc": "" - }, - "text-font": { - "type": "string", - "doc": "Font stack to use for displaying text." - }, - "text-max-size": { - "type": "number", - "default": 16, - "doc": "The maximum size text will be displayed." - }, - "text-max-width": { - "type": "number", - "default": 15, - "doc": "The maximum line width for text wrapping (em)." - }, - "text-line-height": { - "type": "number", - "default": 1.2, - "doc": "Text leading value for multi-line text." - }, - "text-letter-spacing": { - "type": "number", - "default": 0, - "doc": "Text kerning value (em)." - }, - "text-alignment": { - "type": "enum", - "values": [ - "center", - "left", - "right" - ], - "default": "center", - "doc": "Text alignment options." - }, - "text-vertical-alignment": { - "type": "enum", - "values": [ - "top", - "center", - "bottom" - ], - "default": "center", - "doc": "Vertical text alignment options." - }, - "text-max-angle": { - "type": "number", - "doc": "@TODO" - }, - "text-min-distance": { - "type": "number", - "default": 250, - "doc": "Minimum distance between two text labels (px)." - }, - "text-rotate": { - "type": "number", - "default": 0 - }, - "text-slant": { - "type": "number", - "doc": "@TODO" - }, - "text-padding": { - "type": "number", - "default": 2, - "doc": "Padding value around text bounding box to avoid label collisions (px)." - }, - "text-transform": { - "type": "enum", - "values": [ - "none", - "uppercase", - "lowercase" - ], - "default": "none" - }, - "text-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true - }, - "text-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "map" - }, - "text-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the text will be visible even if it collides with other icons and labels." - }, - "text-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, the text won't affect placement of other icons and labels." - } - }, - "render_composite": { - "type": { - "type": "enum", - "values": [ - "composite" - ] - } - }, - "render_raster": { - "type": { - "type": "enum", - "values": [ - "raster" - ] - } - }, - "filter": [ - { - "type": "filter_expression", - "doc": "Various filter expressions. Unless overridden by parent, these are interpreted as `AND`." - }, - { - "type": "array", - "value": "filter_expression", - "doc": "Various filter expressions. Unless overridden by parent, these are interpreted as `OR`." - } - ], - "filter_expression": { - "&": { - "type": "filter", - "doc": "AND operator." - }, - "|": { - "type": "filter", - "doc": "OR operator." - }, - "^": { - "type": "filter", - "doc": "XOR operator." - }, - "!": { - "type": "filter", - "doc": "NOR operator." - }, - "$type": { - "type": "enum", - "values": [ - "any", - "point", - "line", - "polygon" - ], - "default": "any", - "doc": "Geometry type that features must match." - }, - "*": [ - { - "type": "filter_comparison", - "doc": "Arbitarily named feature member. A comparison object defining a filter expression." - }, - { - "type": "filter_value", - "doc": "Arbitarily named feature member. A filter_value implies the equality (string/number/boolean) or set membership operator (array)." - } - ] - }, - "filter_comparison": { - "==": { - "type": "filter_value", - "doc": "Equality operator." - }, - "===": { - "type": "filter_value", - "doc": "Set equality operator." - }, - "!=": { - "type": "filter_value", - "doc": "Inequality operator." - }, - "!==": { - "type": "filter_value", - "doc": "Set inequality operator." - }, - ">": { - "type": "filter_value", - "doc": "Greater than operator." - }, - ">=": { - "type": "filter_value", - "doc": "Greater or equal than operator." - }, - "<": { - "type": "filter_value", - "doc": "Less than operator." - }, - "<=": { - "type": "filter_value", - "doc": "Less than or equal operator." - }, - "in": { - "type": "array", - "value": "filter_primitive", - "doc": "Set member operator." - }, - "!in": { - "type": "array", - "value": "filter_primitive", - "doc": "Not in set operator." - } - }, - "filter_value": [ - { - "type": "filter_primitive" - }, - { - "type": "array", - "value": "filter_primitive" - } - ], - "filter_primitive": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - } - ], - "function": [ - { - "fn": { - "type": "enum", - "required": true, - "values": [ - "stops" - ] - }, - "stops": { - "type": "array", - "required": true, - "doc": "An array of stops.", - "value": "function_stop" - } - }, - { - "fn": { - "required": true, - "type": "enum", - "values": [ - "exponential", - "linear" - ] - }, - "z": { - "type": "number", - "required": true, - "doc": "Base zoom level for the specified value." - }, - "val": [ - { - "type": "number", - "required": true - }, - { - "type": "boolean", - "required": true - } - ], - "slope": { - "type": "number", - "default": 1 - }, - "min": { - "type": "number", - "default": 0 - }, - "max": { - "type": "number", - "default": 0 - } - } - ], - "function_stop": { - "type": "array", - "value": "number", - "length": 2, - "doc": "Zoom level and value pair." - }, - "class": [ - "class_fill", - "class_line", - "class_icon", - "class_text", - "class_composite", - "class_raster", - "class_background" - ], - "class_fill": { - "fill-enabled": { - "type": "boolean", - "function": true, - "default": true, - "transition": true - }, - "fill-antialias": { - "type": "boolean", - "default": true, - "function": true, - "doc": "Whether or not the fill should be antialiased." - }, - "fill-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "fill-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true - }, - "fill-outline-color": { - "type": "color", - "doc": "The outline color of the fill. Matches the value of 'fill-color' if unspecified.", - "transition": true - }, - "fill-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true - }, - "fill-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "map" - }, - "fill-image": { - "type": "string" - } - }, - "class_line": { - "line-enabled": { - "type": "boolean", - "function": true, - "default": true, - "transition": true - }, - "line-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "line-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "transition": true - }, - "line-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true - }, - "line-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "map" - }, - "line-width": { - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "line-offset": { - "type": "number", - "default": 0, - "doc": "Offset from the center line.", - "function": true, - "transition": true - }, - "line-blur": { - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "line-dasharray": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 1, - -1 - ], - "function": true, - "transition": true - }, - "line-image": { - "type": "string", - "doc": "Name of image in sprite to use for drawing image lines." - } - }, - "class_icon": { - "icon-enabled": { - "type": "boolean", - "default": true, - "function": true, - "transition": true - }, - "icon-opacity": { - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "icon-rotate": { - "type": "number", - "default": 0, - "function": true - }, - "icon-rotate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "viewport", - "doc": "Orientation of icon when map is rotated." - } - }, - "class_text": { - "text-enabled": { - "type": "boolean", - "default": true, - "function": true, - "transition": true - }, - "text-opacity": { - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "text-size": { - "type": "number", - "default": 16, - "function": true, - "transition": true, - "doc": "Font size in pixels. If unspecified, the text will be as big as allowed by the layer definition." - }, - "text-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "transition": true - }, - "text-halo-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 0 - ], - "transition": true - }, - "text-halo-width": { - "type": "number", - "default": 0.25, - "function": true, - "transition": true, - "doc": "How far away the halo is from the font outline. A value of 0.75 means that it is as wide as the font outline. Lower values make the halo bigger, higher values make it smaller. TODO: Refactor this to be more sane." - }, - "text-halo-blur": { - "type": "number", - "default": 1, - "function": true, - "transition": true, - "doc": "Fade out the halo towards the outside. 1 means no fade out. Higher values mean a higher fade out." - } - }, - "class_composite": { - "composite-enabled": { - "type": "boolean", - "default": true, - "function": true, - "transition": true - }, - "composite-opacity": { - "type": "number", - "default": 1, - "function": true, - "transition": true - } - }, - "class_raster": { - "raster-enabled": { - "type": "boolean", - "default": true, - "function": true, - "transition": true - }, - "raster-opacity": { - "type": "number", - "default": 1, - "transition": true - }, - "raster-spin": { - "type": "number", - "default": 0, - "function": true, - "transition": true - }, - "raster-brightness": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 1 - ], - "function": true, - "transition": true - }, - "raster-saturation": { - "type": "number", - "default": 0, - "function": true, - "transition": true - }, - "raster-contrast": { - "type": "number", - "default": 0, - "function": true, - "transition": true - }, - "raster-fade": { - "type": "number", - "function": true, - "transition": true - } - }, - "class_background": { - "background-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true - }, - "background-image": { - "type": "string" - } - }, - "transition": { - "duration": { - "type": "number" - }, - "delay": { - "type": "number" - } - } -} diff --git a/reference/v4.json b/reference/v4.json deleted file mode 100644 index fb792b3..0000000 --- a/reference/v4.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "$version": 4, - "$root": { - "version": { - "required": true, - "type": "enum", - "values": [ - 4 - ], - "doc": "Stylesheet version number. Must be 4." - }, - "constants": { - "type": "constants", - "doc": "An object of constants to be referenced in layers." - }, - "sources": { - "required": true, - "type": "sources", - "doc": "Data source definitions for layers." - }, - "layers": { - "required": true, - "type": "array", - "value": "layer", - "doc": "An array of layers. Layers are drawn in the order given." - }, - "sprite": { - "type": "sprite", - "doc": "Sprite definition." - }, - "glyphs": { - "type": "string", - "doc": "A URL template for loading signed-distance-field glyph sets in protocol buffer format. Valid tokens are {fontstack} and {range}." - }, - "transition": { - "type": "transition", - "doc": "A global transition definition to use as a default across properties." - } - }, - "sprite": [{ - "type": "string", - "doc": "A base URL for retrieving the sprite image and metadata. The extensions `.png`, `.json` and scale factor `@2x.png` will be automatically appended." - }], - "constants": { - "*": { - "type": "*", - "doc": "Values that can be declared in one place and referenced through the style. Constants can be any type, including objects and arrays. Constant names must be prefixed with an `@` symbol." - } - }, - "sources": { - "*": { - "type": "source" - } - }, - "source": { - "type": { - "required": true, - "type": "enum", - "values": [ - "vector", - "raster", - "geojson", - "video" - ], - "doc": "The data type of the source." - }, - "url": { - "required": true, - "type": "string", - "doc": "A URL, or URL template to retrieve the source data." - }, - "tileSize": { - "type": "number", - "default": 512, - "doc": "The minimum visual size (in px) to display tiles for this layer. Only configurable for raster layers." - }, - "minZoom": { - "type": "number", - "default": 0, - "doc": "Minimum zoom level for which tiles are available." - }, - "maxZoom": { - "type": "number", - "default": 22, - "doc": "Maximum zoom level for which tiles are available. Data from tiles at the maxZoom are used when displaying the map at higher zoom levels." - }, - "*": { - "type": "*", - "doc": "Other keys to configure the data source." - } - }, - "layer": { - "id": { - "type": "string", - "doc": "Unique layer name." - }, - "type": { - "type": "enum", - "values": [ - "fill", - "line", - "symbol", - "raster", - "background" - ], - "doc": "Rendering type of this layer." - }, - "ref": { - "type": "string", - "doc": "References another layer to copy `source`, `source_layer`, `filter`, and `render` properties from. This allows the layers to share processing and be more efficient." - }, - "source": { - "type": "string", - "doc": "Name of a source description to be used for this layer." - }, - "source-layer": { - "type": "string", - "doc": "Layer to use from a vector tile source. Required if the source supports multiple layers." - }, - "min-zoom": { - "type": "number", - "doc": "The minimum zoom level at which the layer is parsed and visible." - }, - "max-zoom": { - "type": "number", - "doc": "The maximum zoom level at which the layer is parsed and visible." - }, - "interactive": { - "type": "boolean", - "doc": "Enable querying of feature data from this layer for interactivity.", - "default": false - }, - "render": { - "type": "render", - "doc": "Symbolizer type that should be used to visualize this layer. If unspecified or null, this layer is not treated as a symbolizer and only exists to have properties inherited to other layers using ref." - }, - "filter": { - "type": "filter", - "doc": "Array or object of filters or expressions." - }, - "layers": { - "type": "array", - "value": "layer", - "doc": "If `type` is `raster`, the child layers are composited together onto the previous level layer level." - }, - "style": { - "type": "class", - "doc": "Default style properties for this layer." - }, - "style.*": { - "type": "class", - "doc": "Override style properties for this layer. The class name is the part after the first dot." - } - }, - "render": [ - "render_fill", - "render_line", - "render_symbol", - "render_raster", - "render_background" - ], - "render_background": { - }, - "render_fill": { - }, - "render_line": { - "line-cap": { - "type": "enum", - "values": [ - "butt", - "round", - "square" - ], - "default": "butt", - "doc": "The display of line endings." - }, - "line-join": { - "type": "enum", - "values": [ - "bevel", - "round", - "miter" - ], - "default": "miter", - "doc": "The display of lines when joining." - }, - "line-miter-limit": { - "type": "number", - "default": 2, - "doc": "Used to automatically convert miter joins to bevel joins for sharp angles." - }, - "line-round-limit": { - "type": "number", - "default": 1, - "doc": "Used to automatically convert round joins to miter joins for shallow angles." - } - }, - "render_symbol": { - "symbol-placement": { - "type": "enum", - "values": [ - "point", - "line" - ], - "default": "point", - "doc": "Placement of a label relative to its geometry. `Line` can only be used on LineStrings and Polygons." - }, - "symbol-min-distance": { - "type": "number", - "default": 250, - "doc": "Minimum distance between two symbol anchors (px)" - }, - "symbol-avoid-edges": { - "type": "boolean", - "default": false, - "doc": "If true, the symbols will not cross tile edges. Symbols that cross tile edges may cause collisions in some cases. This property should be set to true if the layer does not have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer." - }, - "icon-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the icon will be visible even if it collides with other icons and text." - }, - "icon-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, the icon won't affect placement of other icons and text." - }, - "icon-optional": { - "type": "boolean", - "default": false, - "doc": "If true, text can be shown without its corresponding icon." - }, - "icon-rotation-alignment": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "viewport", - "doc": "Orientation of icon when map is rotated" - }, - "icon-max-size": { - "type": "number", - "default": 1, - "doc": "The maximum amount to scale the icon by." - }, - "icon-image": { - "type": "string", - "doc": "A string with {tokens} replaced, referencing the data property to pull from." - }, - "icon-rotate": { - "type": "number", - "default": 0, - "doc": "Rotates the icon clockwise by the specified number of degrees." - }, - "icon-padding": { - "type": "number", - "default": 2, - "doc": "Padding value around icon bounding box to avoid icon collisions (px)." - }, - "icon-keep-upright": { - "type": "boolean", - "default": false, - "doc": "If true, the icon may be flipped to prevent it from being rendered upside-down" - }, - "icon-offset": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "doc": "Icon's offset, in pixels. Values are [x, y] where negatives indicate left and up, respectively." - }, - "text-rotation-alignment": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "viewport", - "doc": "Orientation of icon or text when map is rotated" - }, - "text-field": { - "type": "string", - "default": "", - "doc": "Value to use for a text label. Feature properties are specified using tokens like {field_name}." - }, - "text-font": { - "type": "string", - "doc": "Font stack to use for displaying text." - }, - "text-max-size": { - "type": "number", - "default": 16, - "doc": "The maximum size text will be displayed." - }, - "text-max-width": { - "type": "number", - "default": 15, - "doc": "The maximum line width for text wrapping (em)." - }, - "text-line-height": { - "type": "number", - "default": 1.2, - "doc": "Text leading value for multi-line text." - }, - "text-letter-spacing": { - "type": "number", - "default": 0, - "doc": "Text kerning value (em)." - }, - "text-justify": { - "type": "enum", - "values": [ - "center", - "left", - "right" - ], - "default": "center", - "doc": "Text justification options." - }, - "text-horizontal-align": { - "type": "enum", - "values": [ - "left", - "center", - "right" - ], - "default": "center", - "doc": "Horizontal alignment of the text relative to the anchor." - }, - "text-vertical-align": { - "type": "enum", - "values": [ - "top", - "center", - "bottom" - ], - "default": "center", - "doc": "Vertical alignment of the text relative to the anchor." - }, - "text-max-angle": { - "type": "number", - "default": 45, - "doc": "The maximum angle change allowed between adjacent characters. Value is given as degrees." - }, - "text-rotate": { - "type": "number", - "default": 0, - "doc": "Rotates the text clockwise by the specified number of degrees." - }, - "text-padding": { - "type": "number", - "default": 2, - "doc": "Padding value around text bounding box to avoid label collisions. Value is given as pixels." - }, - "text-keep-upright": { - "type": "boolean", - "default": true, - "doc": "If true, the direction of the text may be flipped to prevent it from being rendered upside-down" - }, - "text-transform": { - "type": "enum", - "values": [ - "none", - "uppercase", - "lowercase" - ], - "default": "none", - "doc": "Specifies how to capitalize text, similar to the CSS `text-transform` property." - }, - "text-offset": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ] - }, - "text-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the text will be visible even if it collides with other icons and labels." - }, - "text-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, the text won't affect placement of other icons and labels." - }, - "text-optional": { - "type": "boolean", - "default": false, - "doc": "If true, icons can be shown without their corresponding text." - } - }, - "render_raster": { - "raster-size": { - "type": "number", - "function": true, - "default": 256, - "doc": "The texture image size vector layers will be rasterized at. Will automatically by scaled to match the visual tile size. Value is given in pixels." - }, - "raster-blur": { - "type": "number", - "function": true, - "default": 0, - "doc": "Blur radius to apply to the raster texture before display." - } - }, - "filter": [ - { - "type": "filter_expression", - "doc": "Various filter expressions. Unless overridden by parent, these are interpreted as `AND`." - }, - { - "type": "array", - "value": "filter_expression", - "doc": "Various filter expressions. Unless overridden by parent, these are interpreted as `OR`." - } - ], - "filter_expression": { - "&": { - "type": "filter", - "doc": "AND operator." - }, - "|": { - "type": "filter", - "doc": "OR operator." - }, - "^": { - "type": "filter", - "doc": "XOR operator." - }, - "!": { - "type": "filter", - "doc": "NOR operator." - }, - "$type": { - "type": "enum", - "values": [ - "Point", - "LineString", - "Polygon" - ], - "doc": "Geometry type that features must match." - }, - "*": [ - { - "type": "filter_comparison", - "doc": "Arbitrarily named feature member. A comparison object defining a filter expression." - }, - { - "type": "filter_value", - "doc": "Arbitrarily named feature member. A filter_value implies the equality (string/number/boolean) or set membership operator (array)." - } - ] - }, - "filter_comparison": { - "==": { - "type": "filter_value", - "doc": "Equality operator." - }, - "!=": { - "type": "filter_value", - "doc": "Inequality operator." - }, - ">": { - "type": "filter_value", - "doc": "Greater than operator." - }, - ">=": { - "type": "filter_value", - "doc": "Greater or equal than operator." - }, - "<": { - "type": "filter_value", - "doc": "Less than operator." - }, - "<=": { - "type": "filter_value", - "doc": "Less than or equal operator." - }, - "in": { - "type": "array", - "value": "filter_primitive", - "doc": "Set member operator." - }, - "!in": { - "type": "array", - "value": "filter_primitive", - "doc": "Not in set operator." - } - }, - "filter_value": [ - { - "type": "filter_primitive" - }, - { - "type": "array", - "value": "filter_primitive" - } - ], - "filter_primitive": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - } - ], - "function": { - "stops": { - "type": "array", - "required": true, - "doc": "An array of stops.", - "value": "function_stop" - }, - "base": { - "type": "number", - "default": 1, - "doc": "The exponential base of the interpolation curve. This controls the rate at which the result increases. Higher values make the result increase more toward the high end of the range. With `1` the stops are interpolated linearly." - } - }, - "function_stop": { - "type": "array", - "value": ["number", "color"], - "length": 2, - "doc": "Zoom level and value pair." - }, - "class": [ - "class_fill", - "class_line", - "class_symbol", - "class_raster", - "class_background" - ], - "class_fill": { - "fill-antialias": { - "type": "boolean", - "default": true, - "function": true, - "doc": "Whether or not the fill should be antialiased." - }, - "fill-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "fill-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true - }, - "fill-outline-color": { - "type": "color", - "doc": "The outline color of the fill. Matches the value of `fill-color` if unspecified.", - "function": true, - "transition": true - }, - "fill-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "doc": "The geometry's offset, in pixels. Values are [x, y] where negatives indicate left and up, respectively." - }, - "fill-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the fill-translate setting is relative to the map (north) or viewport (screen)", - "default": "map" - }, - "fill-image": { - "type": "string", - "doc": "Name of image in sprite to use for drawing image fills." - } - }, - "class_line": { - "line-opacity": { - "type": "number", - "function": true, - "default": 1, - "transition": true - }, - "line-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true - }, - "line-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "doc": "The geometry's offset, in pixels. Values are [x, y] where negatives indicate left and up, respectively." - }, - "line-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - }, - "line-width": { - "type": "number", - "default": 1, - "function": true, - "transition": true, - "doc": "Line width (in px)" - }, - "line-offset": { - "type": "number", - "default": 0, - "doc": "Line casing where `line-offset` indicates total width. @TODO rename?", - "function": true, - "transition": true - }, - "line-blur": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "Line blur, in pixels." - }, - "line-dasharray": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 1, - -1 - ], - "function": true, - "transition": true - }, - "line-image": { - "type": "string", - "doc": "Name of image in sprite to use for drawing image lines." - } - }, - "class_symbol": { - "icon-opacity": { - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "icon-size": { - "type": "number", - "default": 1, - "function": true, - "transition": true, - "doc": "A scale transformation applied to icons. 1 is original size, 3 triples the size." - }, - "icon-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true, - "doc": "The color of the icon. This can only be used with signed distance field icons." - }, - "icon-halo-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 0 - ], - "function": true, - "transition": true, - "doc": "The color of the icon's halo. Icon halos can only be used with signed distance field icons." - }, - "icon-halo-width": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "How far away the halo is from the icon outline, in pixels." - }, - "icon-halo-blur": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "Fade out the halo towards the outside, in pixels." - }, - "icon-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "doc": "An icon's offset, in pixels. Values are [x, y] where negatives indicate left and up, respectively." - }, - "icon-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - }, - "text-opacity": { - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "text-size": { - "type": "number", - "default": 16, - "function": true, - "transition": true, - "doc": "Font size in pixels. If unspecified, the text will be as big as allowed by the layer definition." - }, - "text-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true - }, - "text-halo-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 0 - ], - "function": true, - "transition": true - }, - "text-halo-width": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "How far away the halo is from the font outline, in pixels. Max text halo width is 1/4 of the font-size (px)." - }, - "text-halo-blur": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "Fade out the halo towards the outside, in pixels." - }, - "text-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "doc": "A label's offset, in pixels. Values are [x, y] where negatives indicate left and up, respectively." - }, - "text-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - } - }, - "class_raster": { - "raster-opacity": { - "type": "number", - "default": 1, - "transition": true - }, - "raster-hue-rotate": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "Rotates hues around the color wheel by the specified number of degrees." - }, - "raster-brightness": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 1 - ], - "function": true, - "transition": true - }, - "raster-saturation": { - "type": "number", - "default": 0, - "function": true, - "transition": true - }, - "raster-contrast": { - "type": "number", - "default": 0, - "function": true, - "transition": true - }, - "raster-fade": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "doc": "Duration of the fade when a new tile is added. @TODO rename?" - } - }, - "class_background": { - "background-color": { - "type": "color", - "default": [ - 0, - 0, - 0, - 1 - ], - "function": true, - "transition": true - }, - "background-image": { - "type": "string" - } - }, - "transition": { - "duration": { - "type": "number", - "default": 300, - "doc": "Time in milliseconds that it takes for transitions to complete." - }, - "delay": { - "type": "number", - "default": 0, - "doc": "Time in milliseconds before a transition begins." - } - } -} diff --git a/reference/v5.json b/reference/v5.json deleted file mode 100644 index 33f47d4..0000000 --- a/reference/v5.json +++ /dev/null @@ -1,912 +0,0 @@ -{ - "$version": 5, - "$root": { - "version": { - "required": true, - "type": "enum", - "values": [ - 5 - ], - "doc": "Stylesheet version number. Must be 5." - }, - "constants": { - "type": "constants", - "doc": "An object of constants to be referenced in layers." - }, - "sources": { - "required": true, - "type": "sources", - "doc": "Data source specifications for layers to pull from." - }, - "layers": { - "required": true, - "type": "array", - "value": "layer", - "doc": "Layers will be drawn in the order of this array." - }, - "sprite": { - "type": "string", - "doc": "A base URL for retrieving the sprite image and metadata. The extensions `.png`, `.json` and scale factor `@2x.png` will be automatically appended." - }, - "glyphs": { - "type": "string", - "doc": "A URL template for loading signed-distance-field glyph sets in PBF format. Valid tokens are {fontstack} and {range}." - }, - "transition": { - "type": "transition", - "doc": "A global transition definition to use as a default across properties." - } - }, - "constants": { - "*": { - "type": "*", - "doc": "A constant that will be replaced verbatim in the referencing place. This can be anything, including objects and arrays. All variable names must be prefixed with an `@` symbol." - } - }, - "sources": { - "*": { - "type": "source", - "doc": "Specification of a data source. For vector and raster sources, either TileJSON or a URL to a TileJSON must be provided. For GeoJSON and video sources, a URL must be provided." - } - }, - "source": { - "type": { - "required": true, - "type": "enum", - "values": [ - "vector", - "raster", - "geojson", - "video" - ], - "doc": "The data type of the source." - }, - "url": { - "type": "string", - "doc": "A URL to a TileJSON resource. Supported protocols are `http:`, `https:`, and `mapbox://`." - }, - "tiles": { - "type": "string", - "doc": "An array of one or more tile source URLs, as in the TileJSON spec." - }, - "minzoom": { - "type": "number", - "default": 0, - "doc": "Minimum zoom level for which tiles are available, as in the TileJSON spec." - }, - "maxzoom": { - "type": "number", - "default": 22, - "doc": "Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." - }, - "tileSize": { - "type": "number", - "default": 512, - "units": "pixels", - "doc": "The minimum visual size to display tiles for this layer. Only configurable for raster layers." - }, - "*": { - "type": "*", - "doc": "Other keys to configure the data source." - } - }, - "layer": { - "id": { - "type": "string", - "doc": "Unique layer name." - }, - "type": { - "type": "enum", - "values": [ - "fill", - "line", - "symbol", - "raster", - "background" - ], - "doc": "Rendering type of this layer." - }, - "ref": { - "type": "string", - "doc": "References another layer to copy `type`, `source`, `source-layer`, `min-zoom`, `max-zoom`, `filter`, and `render` properties from. This allows the layers to share processing and be more efficient." - }, - "source": { - "type": "string", - "doc": "Name of a source description to be used for this layer." - }, - "source-layer": { - "type": "string", - "doc": "Layer to use from a vector tile source. Required if the source supports multiple layers." - }, - "min-zoom": { - "type": "number", - "doc": "The minimum zoom level on which the layer gets parsed and appears on." - }, - "max-zoom": { - "type": "number", - "doc": "The maximum zoom level on which the layer gets parsed and appears on." - }, - "interactive": { - "type": "boolean", - "doc": "Enable querying of feature data from this layer for interactivity.", - "default": false - }, - "render": { - "type": "render", - "doc": "Symbolizer type that should be used to visualize this layer. If unspecified or null, this layer is not treated as a symbolizer and only exists to have properties inherited to other layers using ref." - }, - "filter": { - "type": "filter", - "doc": "Array or object of filters or expressions." - }, - "layers": { - "type": "array", - "value": "layer", - "doc": "If `type` is `raster`, the child layers are composited together onto the previous level layer level." - }, - "style": { - "type": "class", - "doc": "Default style properties for this layer." - }, - "style.*": { - "type": "class", - "doc": "Override style properties for this layer. The class name is the part after the first dot." - } - }, - "render": [ - "render_fill", - "render_line", - "render_symbol", - "render_raster", - "render_background" - ], - "render_background": { - }, - "render_fill": { - }, - "render_line": { - "line-cap": { - "type": "enum", - "values": [ - "butt", - "round", - "square" - ], - "default": "butt", - "doc": "The display of line endings." - }, - "line-join": { - "type": "enum", - "values": [ - "bevel", - "round", - "miter" - ], - "default": "miter", - "doc": "The display of lines when joining." - }, - "line-miter-limit": { - "type": "number", - "default": 2, - "doc": "Used to automatically convert miter joins to bevel joins for sharp angles." - }, - "line-round-limit": { - "type": "number", - "default": 1, - "doc": "Used to automatically convert round joins to miter joins for shallow angles." - } - }, - "render_symbol": { - "symbol-placement": { - "type": "enum", - "values": [ - "point", - "line" - ], - "default": "point", - "doc": "Label placement relative to its geometry. `Line` can only be used on LineStrings and Polygons." - }, - "symbol-min-distance": { - "type": "number", - "default": 250, - "units": "pixels", - "doc": "Minimum distance between two symbol anchors." - }, - "symbol-avoid-edges": { - "type": "boolean", - "default": false, - "doc": "If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer." - }, - "icon-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the icon will be visible even if it collides with other icons and text." - }, - "icon-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, the icon won't affect placement of other icons and text." - }, - "icon-optional": { - "type": "boolean", - "default": false, - "doc": "If true, text can be shown without its corresponding icon." - }, - "icon-rotation-alignment": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "viewport", - "doc": "Orientation of icon when map is rotated" - }, - "icon-max-size": { - "type": "number", - "default": 1, - "doc": "The maximum factor to scale the icon." - }, - "icon-image": { - "type": "string", - "doc": "A string with {tokens} replaced, referencing the data property to pull from.", - "tokens": true - }, - "icon-rotate": { - "type": "number", - "default": 0, - "units": "degrees", - "doc": "Rotates the icon clockwise." - }, - "icon-padding": { - "type": "number", - "default": 2, - "units": "pixels", - "doc": "Padding value around icon bounding box to avoid icon collisions." - }, - "icon-keep-upright": { - "type": "boolean", - "default": false, - "doc": "If true, the icon may be flipped to prevent it from being rendered upside-down" - }, - "icon-offset": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "units": "pixels", - "doc": "Icon's offset distance. Values are [x, y] where negatives indicate left and up, respectively." - }, - "text-rotation-alignment": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "default": "viewport", - "doc": "Orientation of icon or text when map is rotated" - }, - "text-field": { - "type": "string", - "default": "", - "tokens": true, - "doc": "Value to use for a text label. Feature properties are specified using tokens like {field_name}." - }, - "text-font": { - "type": "string", - "doc": "Font stack to use for displaying text." - }, - "text-max-size": { - "type": "number", - "default": 16, - "units": "pixels", - "doc": "The maximum size text will be displayed." - }, - "text-max-width": { - "type": "number", - "default": 15, - "units": "em", - "doc": "The maximum line width for text wrapping." - }, - "text-line-height": { - "type": "number", - "default": 1.2, - "doc": "Text leading value for multi-line text." - }, - "text-letter-spacing": { - "type": "number", - "default": 0, - "units": "em", - "doc": "Text kerning value." - }, - "text-justify": { - "type": "enum", - "values": [ - "center", - "left", - "right" - ], - "default": "center", - "doc": "Text justification options." - }, - "text-horizontal-align": { - "type": "enum", - "values": [ - "left", - "center", - "right" - ], - "default": "center", - "doc": "Horizontal alignment of the text relative to the anchor." - }, - "text-vertical-align": { - "type": "enum", - "values": [ - "top", - "center", - "bottom" - ], - "default": "center", - "doc": "Vertical alignment of the text relative to the anchor." - }, - "text-max-angle": { - "type": "number", - "default": 45, - "units": "degrees", - "doc": "Maximum angle change between adjacent characters." - }, - "text-rotate": { - "type": "number", - "default": 0, - "units": "degrees", - "doc": "Rotates the text clockwise." - }, - "text-padding": { - "type": "number", - "default": 2, - "units": "pixels", - "doc": "Padding value around text bounding box to avoid label collisions." - }, - "text-keep-upright": { - "type": "boolean", - "default": true, - "doc": "If true, the text may be flipped vertically to prevent it from being rendered upside-down." - }, - "text-transform": { - "type": "enum", - "values": [ - "none", - "uppercase", - "lowercase" - ], - "default": "none", - "doc": "Specifies how to capitalize text, similar to the CSS `text-transform` property." - }, - "text-offset": { - "type": "array", - "doc": "Specifies the distance that text is offset from its anchor horizontally and vertically.", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ] - }, - "text-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the text will be visible even if it collides with other icons and labels." - }, - "text-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, the text won't affect placement of other icons and labels." - }, - "text-optional": { - "type": "boolean", - "default": false, - "doc": "If true, icons can be shown without their corresponding text." - } - }, - "render_raster": { - "raster-size": { - "type": "number", - "function": true, - "default": 256, - "units": "pixels", - "doc": "The texture image size at which vector layers will be rasterized. Will scale to match the visual tile size." - }, - "raster-blur": { - "type": "number", - "function": true, - "default": 0, - "units": "pixels", - "doc": "Blur radius applied to the raster texture before display." - } - }, - "filter": [ - { - "type": "filter_expression", - "doc": "Various filter expressions. Unless overridden by parent, these are interpreted as `AND`." - }, - { - "type": "array", - "value": "filter_expression", - "doc": "Various filter expressions. Unless overridden by parent, these are interpreted as `OR`." - } - ], - "filter_expression": { - "&": { - "type": "filter", - "doc": "AND operator." - }, - "|": { - "type": "filter", - "doc": "OR operator." - }, - "^": { - "type": "filter", - "doc": "XOR operator." - }, - "!": { - "type": "filter", - "doc": "NOR operator." - }, - "$type": { - "type": "enum", - "values": [ - "Point", - "LineString", - "Polygon" - ], - "doc": "Geometry type that features must match." - }, - "*": [ - { - "type": "filter_comparison", - "doc": "Arbitarily named feature member. A comparison object defining a filter expression." - }, - { - "type": "filter_value", - "doc": "Arbitarily named feature member. A filter_value implies the equality (string/number/boolean) or set membership operator (array)." - } - ] - }, - "filter_comparison": { - "==": { - "type": "filter_value", - "doc": "Equality operator." - }, - "!=": { - "type": "filter_value", - "doc": "Inequality operator." - }, - ">": { - "type": "filter_value", - "doc": "Greater than operator." - }, - ">=": { - "type": "filter_value", - "doc": "Greater or equal than operator." - }, - "<": { - "type": "filter_value", - "doc": "Less than operator." - }, - "<=": { - "type": "filter_value", - "doc": "Less than or equal operator." - }, - "in": { - "type": "array", - "value": "filter_primitive", - "doc": "Set member operator." - }, - "!in": { - "type": "array", - "value": "filter_primitive", - "doc": "Not in set operator." - } - }, - "filter_value": [ - { - "type": "filter_primitive" - }, - { - "type": "array", - "value": "filter_primitive" - } - ], - "filter_primitive": [ - { - "type": "string" - }, - { - "type": "number" - }, - { - "type": "boolean" - } - ], - "function": { - "stops": { - "type": "array", - "required": true, - "doc": "An array of stops.", - "value": "function_stop" - }, - "base": { - "type": "number", - "default": 1, - "doc": "The exponential base of the interpolation curve. It controls the rate at which the result increases. Higher values make the result increase more towards the high end of the range. With `1` the stops are interpolated linearly." - } - }, - "function_stop": { - "type": "array", - "value": [ - "number", - "color" - ], - "length": 2, - "doc": "Zoom level and value pair." - }, - "class": [ - "class_fill", - "class_line", - "class_symbol", - "class_raster", - "class_background" - ], - "class_fill": { - "fill-antialias": { - "type": "boolean", - "default": true, - "function": true, - "doc": "Whether or not the fill should be antialiased." - }, - "fill-opacity": { - "type": "number", - "function": true, - "default": 1, - "doc": "The opacity given to the fill color", - "transition": true - }, - "fill-color": { - "type": "color", - "default": "#000000", - "doc": "The color of the fill.", - "function": true, - "transition": true - }, - "fill-outline-color": { - "type": "color", - "doc": "The outline color of the fill. Matches the value of `fill-color` if unspecified.", - "function": true, - "transition": true - }, - "fill-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "units": "pixels", - "doc": "The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively." - }, - "fill-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - }, - "fill-image": { - "type": "string", - "doc": "Name of image in sprite to use for drawing image fills." - } - }, - "class_line": { - "line-opacity": { - "type": "number", - "doc": "The opacity at which the line will be drawn", - "function": true, - "default": 1, - "transition": true - }, - "line-color": { - "type": "color", - "doc": "The color with which the line will be drawn", - "default": "#000000", - "function": true, - "transition": true - }, - "line-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "units": "pixels", - "doc": "The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively." - }, - "line-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - }, - "line-width": { - "type": "number", - "default": 1, - "function": true, - "transition": true, - "units": "pixels", - "doc": "Stroke thickness" - }, - "line-offset": { - "type": "number", - "default": 0, - "doc": "Line casing where `line-offset` indicates total width. @TODO rename?", - "function": true, - "transition": true - }, - "line-blur": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "units": "pixels", - "doc": "Line blur" - }, - "line-dasharray": { - "type": "array", - "value": "number", - "doc": "Specifies the size and gap between dashes in a line.", - "length": 2, - "default": [ - 1, - -1 - ], - "function": true, - "transition": true - }, - "line-image": { - "type": "string", - "doc": "Name of image in sprite to use for drawing image lines." - } - }, - "class_symbol": { - "icon-opacity": { - "doc": "The opacity at which the icon will be drawn", - "type": "number", - "default": 1, - "function": true, - "transition": true - }, - "icon-size": { - "type": "number", - "default": 1, - "function": true, - "transition": true, - "doc": "Scale factor for icon. 1 is original size, 3 triples the size." - }, - "icon-color": { - "type": "color", - "default": "#000000", - "function": true, - "transition": true, - "doc": "The color of the icon. This can only be used with sdf icons." - }, - "icon-halo-color": { - "type": "color", - "default": "rgba(0, 0, 0, 0)", - "function": true, - "transition": true, - "doc": "The color of the icon's halo. Icon halos can only be used with sdf icons." - }, - "icon-halo-width": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "units": "pixels", - "doc": "Distance of halo to the icon outline." - }, - "icon-halo-blur": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "units": "pixels", - "doc": "Fade out the halo towards the outside." - }, - "icon-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "units": "pixels", - "doc": "An icon's offset distance. Values are [x, y] where negatives indicate left and up, respectively." - }, - "icon-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - }, - "text-opacity": { - "type": "number", - "doc": "The opacity at which the text will be drawn", - "default": 1, - "function": true, - "transition": true - }, - "text-size": { - "type": "number", - "default": 16, - "function": true, - "transition": true, - "units": "pixels", - "doc": "Font size. If unspecified, the text will be as big as allowed by the layer definition." - }, - "text-color": { - "type": "color", - "doc": "The color with which the text will be drawn", - "default": "#000000", - "function": true, - "transition": true - }, - "text-halo-color": { - "type": "color", - "default": "rgba(0, 0, 0, 0)", - "function": true, - "transition": true, - "doc": "The color of the text's halo, which helps it stand out from backgrounds." - }, - "text-halo-width": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "units": "pixels", - "doc": "Distance of halo to the font outline. Max text halo width is 1/4 of the font-size." - }, - "text-halo-blur": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "units": "pixels", - "doc": "The halo's fadeout distance towards the outside." - }, - "text-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "function": true, - "transition": true, - "units": "pixels", - "doc": "Label offset. Values are [x, y] where negatives indicate left and up, respectively." - }, - "text-translate-anchor": { - "type": "enum", - "values": [ - "map", - "viewport" - ], - "doc": "Control whether the translation is relative to the map (north) or viewport (screen)", - "default": "map" - } - }, - "class_raster": { - "raster-opacity": { - "type": "number", - "doc": "The opacity at which the image will be drawn", - "default": 1, - "transition": true - }, - "raster-hue-rotate": { - "type": "number", - "default": 0, - "function": true, - "transition": true, - "units": "degrees", - "doc": "Rotates hues around the color wheel." - }, - "raster-brightness": { - "type": "array", - "value": "number", - "doc": "Increase or reduce the brightness of the image. First value is the minimum, second is the maximum brightness.", - "length": 2, - "default": [ - 0, - 1 - ], - "function": true, - "transition": true - }, - "raster-saturation": { - "type": "number", - "doc": "Increase or reduce the saturation of the image.", - "default": 0, - "function": true, - "transition": true - }, - "raster-contrast": { - "type": "number", - "doc": "Increase or reduce the contrast of the image.", - "default": 0, - "function": true, - "transition": true - }, - "raster-fade-duration": { - "type": "number", - "default": 300, - "function": true, - "transition": true, - "units": "milliseconds", - "doc": "Fade duration when a new tile is added." - } - }, - "class_background": { - "background-color": { - "type": "color", - "default": "#000000", - "doc": "The color with which the background will be drawn", - "function": true, - "transition": true - }, - "background-image": { - "type": "string", - "doc": "Optionally an image which is drawn as the background" - }, - "background-opacity": { - "type": "number", - "default": 1, - "doc": "The opacity at which the background will be drawn", - "function": true, - "transition": true - } - }, - "transition": { - "duration": { - "type": "number", - "default": 300, - "units": "milliseconds", - "doc": "Time allotted for transitions to complete." - }, - "delay": { - "type": "number", - "default": 0, - "units": "milliseconds", - "doc": "Length of time before a transition begins." - } - } -} diff --git a/test/migrate.js b/test/migrate.js index 09e4090..6e33433 100644 --- a/test/migrate.js +++ b/test/migrate.js @@ -13,7 +13,7 @@ var t = require('tape'), var UPDATE = !!process.env.UPDATE; t('migrates to latest version', function(t) { - t.deepEqual(migrate({version: 4, layers: []}).version, spec.latest.$version); + t.deepEqual(migrate({version: 7, layers: []}).version, spec.latest.$version); t.end(); }); diff --git a/test/migrations/v6-filter.js b/test/migrations/v6-filter.js deleted file mode 100644 index 30a1760..0000000 --- a/test/migrations/v6-filter.js +++ /dev/null @@ -1,86 +0,0 @@ -'use strict'; - -var t = require('tape'), - migrate = require('../../migrations/v6-filter'); - -t('basic', function(t) { - t.deepEqual(migrate({a: 'b'}), - ['==', 'a', 'b']); - t.deepEqual(migrate({a: 'b', c: 'd'}), - ['all', ['==', 'a', 'b'], ['==', 'c', 'd']]); - t.end(); -}); - -t('operators', function(t) { - t.deepEqual(migrate({a: {'==': 'b'}}), - ['==', 'a', 'b']); - t.deepEqual(migrate({a: {'>=': 'b'}}), - ['>=', 'a', 'b']); - t.deepEqual(migrate({a: {'in': ['b']}}), - ['in', 'a', 'b']); - t.deepEqual(migrate({a: {'!in': ['b']}}), - ['!in', 'a', 'b']); - t.end(); -}); - -t('arrays', function(t) { - t.deepEqual(migrate({a: ['b', 'c']}), - ['in', 'a', 'b', 'c']); - t.deepEqual(migrate({a: { '!=': ['b', 'c']}}), - ['all', ['!=', 'a', 'b'], ['!=', 'a', 'c']]); - t.end(); -}); - -t('&', function(t) { - t.deepEqual(migrate({'&': { 'a': 'b', 'c': 'd' }}), - ['all', ['==', 'a', 'b'], ['==', 'c', 'd']]); - t.end(); -}); - -t('|', function(t) { - t.deepEqual(migrate({'|': { 'a': 'b', 'c': 'd' }}), - ['any', ['==', 'a', 'b'], ['==', 'c', 'd']]); - t.end(); -}); - -t('!', function(t) { - t.deepEqual(migrate({'!': { 'a': 'b' }}), - ['!=', 'a', 'b']); - t.deepEqual(migrate({'!': { 'a': 'b', 'c': 'd' }}), - ['any', ['!=', 'a', 'b'], ['!=', 'c', 'd']]); - t.end(); -}); - -t('example', function(t) { - var f = migrate({ - "class": "street_limited", - "admin_level": { ">=": 3 }, - "!": { "$type": "Polygon" } - }); - t.deepEqual(f, [ - 'all', - ['==', 'class', 'street_limited'], - ['>=', 'admin_level', 3], - ['!=', '$type', 'Polygon'] - ]); - t.end(); -}); - -t('https://github.com/mapbox/mapbox-gl-style-lint/issues/32', function(t) { - var f = migrate({ - "||": [ - { "type": "Aerodrome" }, - { "type": "Rail Station", "scalerank": [0,1] } - ], - "$type": "Point" - }); - t.deepEqual(f, - ['all', - ['any', - ['==', 'type', 'Aerodrome'], - ['all', - ['==', 'type', 'Rail Station'], - ['in', 'scalerank', 0, 1]]], - ['==', '$type', 'Point']]); - t.end(); -}); diff --git a/test/migrations/v6.js b/test/migrations/v6.js deleted file mode 100644 index ef80ed4..0000000 --- a/test/migrations/v6.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict'; - -var t = require('tape'), - migrate = require('../../migrations/v6'); - -t('render ⇢ layout', function(t) { - t.deepEqual(migrate({ - "version": 6, - "layers": [{ - "render": {} - }] - }), { - "version": 6, - "layers": [{ - "layout": {} - }] - }); - t.end(); -}); - -t('style ⇢ paint', function(t) { - t.deepEqual(migrate({ - "version": 6, - "layers": [{ - "style": {}, - "style.class": {} - }] - }), { - "version": 6, - "layers": [{ - "paint": {}, - "paint.class": {} - }] - }); - t.end(); -}); - -t('text-anchor', function(t) { - t.deepEqual(migrate({ - "version": 6, - "layers": [{ - "layout": { - "text-horizontal-align": "center", - "text-vertical-align": "center" - } - }, { - "layout": { - "text-horizontal-align": "left" - } - }, { - "layout": { - "text-horizontal-align": "right" - } - }, { - "layout": { - "text-vertical-align": "top" - } - }, { - "layout": { - "text-vertical-align": "bottom" - } - }, { - "layout": { - "text-vertical-align": "bottom", - "text-horizontal-align": "right" - } - }] - }), { - "version": 6, - "layers": [{ - "layout": { - } - }, { - "layout": { - "text-anchor": "left" - } - }, { - "layout": { - "text-anchor": "right" - } - }, { - "layout": { - "text-anchor": "top" - } - }, { - "layout": { - "text-anchor": "bottom" - } - }, { - "layout": { - "text-anchor": "bottom-right" - } - }] - }); - t.end(); -}); diff --git a/test/spec.js b/test/spec.js index 1738cb4..3fc57c2 100644 --- a/test/spec.js +++ b/test/spec.js @@ -3,7 +3,7 @@ var test = require('tape'); var spec = require('../'); -['v2', 'v3', 'v4', 'v5', 'v6', 'v7', 'v8', 'latest'].forEach(function(v) { +['v6', 'v7', 'v8', 'latest'].forEach(function(v) { test(v, function(t) { for (var k in spec[v]) { // Exception for version.