Skip to content
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
4 changes: 2 additions & 2 deletions src/expression/definitions/coercion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {BooleanType, ColorType, NumberType, StringType, ValueType} from '../types';
import {Color, Padding, VariableAnchorOffsetCollection, toString as valueToString, validateRGBA, Projection} from '../values';
import {Color, Padding, VariableAnchorOffsetCollection, toString as valueToString, validateRGBA} from '../values';
import RuntimeError from '../runtime_error';
import Formatted from '../types/formatted';
import ResolvedImage from '../types/resolved_image';
Expand Down Expand Up @@ -124,7 +124,7 @@ class Coercion implements Expression {
case 'resolvedImage':
return ResolvedImage.fromString(valueToString(this.args[0].evaluate(ctx)));
case 'projection':
return Projection.parse(this.args[0].evaluate(ctx));
return this.args[0].evaluate(ctx);
default:
return valueToString(this.args[0].evaluate(ctx));
}
Expand Down
2 changes: 1 addition & 1 deletion src/expression/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export function normalizePropertyExpression<T>(
} else if (specification.type === 'variableAnchorOffsetCollection' && Array.isArray(value)) {
constant = VariableAnchorOffsetCollection.parse(value as VariableAnchorOffsetCollectionSpecification);
} else if (specification.type === 'projection' && typeof value === 'string') {
constant = Projection.parse(value);
constant = value;
}
return {
kind: 'constant',
Expand Down
2 changes: 1 addition & 1 deletion src/util/interpolate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('interpolate', () => {
});

test('interpolate projection', () => {
const i11nFn = (t: number) => interpolate.projection(Projection.parse('vertical-perspective'), Projection.parse('mercator'), t);
const i11nFn = (t: number) => interpolate.projection('vertical-perspective', 'mercator', t);
expect(i11nFn(0.5)).toBeInstanceOf(Projection);
expect(`${i11nFn(0.5)}`).toBe('["vertical-perspective", "mercator", 0.5]');
});
Expand Down
4 changes: 2 additions & 2 deletions src/util/interpolate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function number(from: number, to: number, t: number): number {
return from + t * (to - from);
}

function projection(from: Projection, to: Projection, interpolation: number): Projection {
return new Projection(from.from, to.to, interpolation);
function projection(from: string, to: string, interpolation: number): Projection {
return new Projection(from, to, interpolation);
}

function color(from: Color, to: Color, t: number, spaceKey: InterpolationColorSpace = 'rgb'): Color {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"type": "projection"
},
"outputs": [
["mercator", "mercator", 1]
"mercator"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"type": "projection"
},
"outputs": [
["vertical-perspective", "vertical-perspective", 1]
"vertical-perspective"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"zoom"
],
0,
["literal", ["vertical-perspective", "vertical-perspective", 1]],
"vertical-perspective",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean literal is no longer supported?

Copy link
Member Author

@birkskyum birkskyum Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes very little sense to me why we want to support literals representing the transition from one transition to the other, unless we want to support transitions between intermediates (which I don't consider particularly useful - I've yet to think of a use):

5,
["vertical-perspective", "mercator", 0.2],
 10,
["equal-earth", "utm23", 0.5]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

10,
["literal", ["mercator", "mercator", 1]]
"mercator"
],
"inputs": [
[
Expand Down