Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit convert functions to output linear interpolation #9107

Merged
merged 4 commits into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/style-spec/function/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ function convertPropertyFunction(parameters, propertySpec, stops) {
];
} else if (type === 'exponential') {
const base = parameters.base !== undefined ? parameters.base : 1;
const expression = [getInterpolateOperator(parameters), ['exponential', base], ['number', get]];
const expression = [
getInterpolateOperator(parameters),
base === 1 ? ["linear"] : ["exponential", base],
["number", get]
];

for (const stop of stops) {
appendStopPair(expression, stop[0], stop[1], false);
}
Expand All @@ -177,7 +182,8 @@ function convertZoomFunction(parameters, propertySpec, stops, input = ['zoom'])
isStep = true;
} else if (type === 'exponential') {
const base = parameters.base !== undefined ? parameters.base : 1;
expression = [getInterpolateOperator(parameters), ['exponential', base], input];
expression = [getInterpolateOperator(parameters), base === 1 ? ["linear"] : ["exponential", base], input];

} else {
throw new Error(`Unknown zoom function type "${type}"`);
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/style-spec/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test('converts stop functions to expressions', (t) => {
}, spec.latest.$version);
t.deepEqual(migrated.layers[0].paint['background-opacity'], [
'interpolate',
['exponential', 1],
['linear'],
['zoom'],
0,
1,
Expand All @@ -78,7 +78,7 @@ test('converts stop functions to expressions', (t) => {
]);
t.deepEqual(migrated.layers[1].paint['background-opacity'], [
'interpolate',
['exponential', 1],
['linear'],
['zoom'],
0,
['literal', [1, 2]],
Expand Down