diff --git a/src/style-spec/expression/definitions/curve.js b/src/style-spec/expression/definitions/curve.js new file mode 100644 index 00000000000..9f51c207a12 --- /dev/null +++ b/src/style-spec/expression/definitions/curve.js @@ -0,0 +1,26 @@ +// @flow + +import type { Expression } from '../expression'; +import type ParsingContext from '../parsing_context'; +import type { Type } from '../types'; + +class Curve implements Expression { + key: string; + type: Type; + + static parse(args: Array, context: ParsingContext) { + const [ , interpolation, input, ...rest] = args; + if ((interpolation: any)[0] === "step") { + return context.error(`"curve" has been replaced by "step" and "interpolate". Replace this expression with ${ + JSON.stringify(["step", input, ...rest])}`, 0); + } else { + return context.error(`"curve" has been replaced by "step" and "interpolate". Replace this expression with ${ + JSON.stringify(["interpolate", interpolation, input, ...rest])}`, 0); + } + } + + evaluate() {} + eachChild() {} +} + +module.exports = Curve; diff --git a/src/style-spec/expression/definitions/index.js b/src/style-spec/expression/definitions/index.js index 078814c5f4b..c933c4872cc 100644 --- a/src/style-spec/expression/definitions/index.js +++ b/src/style-spec/expression/definitions/index.js @@ -25,6 +25,7 @@ const Coercion = require('./coercion'); const At = require('./at'); const Match = require('./match'); const Case = require('./case'); +const Curve = require('./curve'); const Step = require('./step'); const Interpolate = require('./interpolate'); const Coalesce = require('./coalesce'); @@ -47,6 +48,7 @@ const expressions: { [string]: Class } = { 'case': Case, 'match': Match, 'coalesce': Coalesce, + 'curve': Curve, 'step': Step, 'interpolate': Interpolate }; diff --git a/test/integration/expression-tests/curve/interpolate/test.json b/test/integration/expression-tests/curve/interpolate/test.json new file mode 100644 index 00000000000..fc3fbba757a --- /dev/null +++ b/test/integration/expression-tests/curve/interpolate/test.json @@ -0,0 +1,15 @@ +{ + "expression": ["curve", ["linear"], 0, 1, 2, 3, 4], + "inputs": [[{}, {}]], + "expected": { + "compiled": { + "result": "error", + "errors": [ + { + "key": "[0]", + "error": "\"curve\" has been replaced by \"step\" and \"interpolate\". Replace this expression with [\"interpolate\",[\"linear\"],0,1,2,3,4]" + } + ] + } + } +} diff --git a/test/integration/expression-tests/curve/step/test.json b/test/integration/expression-tests/curve/step/test.json new file mode 100644 index 00000000000..cba6732f024 --- /dev/null +++ b/test/integration/expression-tests/curve/step/test.json @@ -0,0 +1,15 @@ +{ + "expression": ["curve", ["step"], 0, 1, 2, 3, 4, 5], + "inputs": [[{}, {}]], + "expected": { + "compiled": { + "result": "error", + "errors": [ + { + "key": "[0]", + "error": "\"curve\" has been replaced by \"step\" and \"interpolate\". Replace this expression with [\"step\",0,1,2,3,4,5]" + } + ] + } + } +}