[darwin] Replace use of *Stops with expressions DSL
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/style/expression/interpolator.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <initializer_list>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -16,6 +17,8 @@ namespace dsl {
|
||||
|
||||
std::unique_ptr<Expression> literal(const char* value);
|
||||
std::unique_ptr<Expression> literal(Value value);
|
||||
std::unique_ptr<Expression> literal(std::initializer_list<double> value);
|
||||
std::unique_ptr<Expression> literal(std::initializer_list<const char *> value);
|
||||
|
||||
std::unique_ptr<Expression> number(std::unique_ptr<Expression>);
|
||||
std::unique_ptr<Expression> string(std::unique_ptr<Expression>);
|
||||
@@ -38,6 +41,10 @@ std::unique_ptr<Expression> gt(std::unique_ptr<Expression>,
|
||||
std::unique_ptr<Expression> lt(std::unique_ptr<Expression>,
|
||||
std::unique_ptr<Expression>);
|
||||
|
||||
std::unique_ptr<Expression> step(std::unique_ptr<Expression> input,
|
||||
std::unique_ptr<Expression> output0,
|
||||
double input1, std::unique_ptr<Expression> output1);
|
||||
|
||||
Interpolator linear();
|
||||
Interpolator exponential(double base);
|
||||
Interpolator cubicBezier(double x1, double y1, double x2, double y2);
|
||||
|
||||
@@ -101,7 +101,7 @@ global.objCTestValue = function (property, layerType, arraysAsStructs, indent) {
|
||||
case 'boolean':
|
||||
return property.default ? '@"false"' : '@"true"';
|
||||
case 'number':
|
||||
return '@"0xff"';
|
||||
return '@"1"';
|
||||
case 'string':
|
||||
return `@"'${_.startCase(propertyName)}'"`;
|
||||
case 'enum':
|
||||
@@ -145,7 +145,7 @@ global.mbglTestValue = function (property, layerType) {
|
||||
case 'boolean':
|
||||
return property.default ? 'false' : 'true';
|
||||
case 'number':
|
||||
return '0xff';
|
||||
return '1.0';
|
||||
case 'string':
|
||||
return `"${_.startCase(propertyName)}"`;
|
||||
case 'enum': {
|
||||
@@ -186,6 +186,18 @@ global.mbglTestValue = function (property, layerType) {
|
||||
}
|
||||
};
|
||||
|
||||
global.mbglExpressionTestValue = function (property, layerType) {
|
||||
let propertyName = originalPropertyName(property);
|
||||
switch (property.type) {
|
||||
case 'enum':
|
||||
return `"${_.last(_.keys(property.values))}"`;
|
||||
case 'color':
|
||||
return 'mbgl::Color(1, 0, 0, 1)';
|
||||
default:
|
||||
return global.mbglTestValue(property, layerType);
|
||||
}
|
||||
};
|
||||
|
||||
global.testGetterImplementation = function (property, layerType, isFunction) {
|
||||
let helperMsg = testHelperMessage(property, layerType, isFunction);
|
||||
let value = `[MGLRuntimeStylingHelper ${helperMsg}]`;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/background_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLBackgroundLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -45,11 +46,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.backgroundColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getBackgroundColor(), propertyValue,
|
||||
@"Setting backgroundColor to a camera expression should update background-color.");
|
||||
@@ -85,23 +87,24 @@
|
||||
@"background-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.backgroundOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.backgroundOpacity = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
|
||||
@"Setting backgroundOpacity to a constant value expression should update background-opacity.");
|
||||
XCTAssertEqualObjects(layer.backgroundOpacity, constantExpression,
|
||||
@"backgroundOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.backgroundOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getBackgroundOpacity(), propertyValue,
|
||||
@"Setting backgroundOpacity to a camera expression should update background-opacity.");
|
||||
@@ -149,11 +152,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.backgroundPattern = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = {{
|
||||
{ -INFINITY, "Background Pattern" },
|
||||
{ 18, "Background Pattern" },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::string>(
|
||||
step(zoom(), literal("Background Pattern"), 18.0, literal("Background Pattern"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getBackgroundPattern(), propertyValue,
|
||||
@"Setting backgroundPattern to a camera expression should update background-pattern.");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/circle_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLCircleLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -54,23 +55,24 @@
|
||||
@"circle-blur should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.circleBlur;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.circleBlur = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a constant value expression should update circle-blur.");
|
||||
XCTAssertEqualObjects(layer.circleBlur, constantExpression,
|
||||
@"circleBlur should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleBlur = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a camera expression should update circle-blur.");
|
||||
@@ -80,8 +82,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleBlur = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a data expression should update circle-blur.");
|
||||
@@ -92,11 +98,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleBlur = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue,
|
||||
@"Setting circleBlur to a camera-data expression should update circle-blur.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -137,11 +145,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a camera expression should update circle-color.");
|
||||
@@ -151,8 +160,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleColor = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a data expression should update circle-color.");
|
||||
@@ -163,11 +176,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleColor = functionExpression;
|
||||
|
||||
std::map<float, mbgl::Color> innerStops { {18, { 1, 0, 0, 1 }} };
|
||||
mbgl::style::CompositeExponentialStops<mbgl::Color> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleColor(), propertyValue,
|
||||
@"Setting circleColor to a camera-data expression should update circle-color.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -196,23 +211,24 @@
|
||||
@"circle-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.circleOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.circleOpacity = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a constant value expression should update circle-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleOpacity, constantExpression,
|
||||
@"circleOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a camera expression should update circle-opacity.");
|
||||
@@ -222,8 +238,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleOpacity = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a data expression should update circle-opacity.");
|
||||
@@ -234,11 +254,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleOpacity = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue,
|
||||
@"Setting circleOpacity to a camera-data expression should update circle-opacity.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -279,11 +301,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circlePitchAlignment = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::AlignmentType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::AlignmentType::Viewport },
|
||||
{ 18, mbgl::style::AlignmentType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::AlignmentType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::AlignmentType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCirclePitchAlignment(), propertyValue,
|
||||
@"Setting circlePitchAlignment to a camera expression should update circle-pitch-alignment.");
|
||||
@@ -310,23 +333,24 @@
|
||||
@"circle-radius should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.circleRadius;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.circleRadius = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a constant value expression should update circle-radius.");
|
||||
XCTAssertEqualObjects(layer.circleRadius, constantExpression,
|
||||
@"circleRadius should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleRadius = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a camera expression should update circle-radius.");
|
||||
@@ -336,8 +360,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleRadius = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a data expression should update circle-radius.");
|
||||
@@ -348,11 +376,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleRadius = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue,
|
||||
@"Setting circleRadius to a camera-data expression should update circle-radius.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -393,11 +423,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleScaleAlignment = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::CirclePitchScaleType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::CirclePitchScaleType::Viewport },
|
||||
{ 18, mbgl::style::CirclePitchScaleType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::CirclePitchScaleType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::CirclePitchScaleType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCirclePitchScale(), propertyValue,
|
||||
@"Setting circleScaleAlignment to a camera expression should update circle-pitch-scale.");
|
||||
@@ -436,11 +467,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleStrokeColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a camera expression should update circle-stroke-color.");
|
||||
@@ -450,8 +482,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleStrokeColor = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a data expression should update circle-stroke-color.");
|
||||
@@ -462,11 +498,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleStrokeColor = functionExpression;
|
||||
|
||||
std::map<float, mbgl::Color> innerStops { {18, { 1, 0, 0, 1 }} };
|
||||
mbgl::style::CompositeExponentialStops<mbgl::Color> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue,
|
||||
@"Setting circleStrokeColor to a camera-data expression should update circle-stroke-color.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -495,23 +533,24 @@
|
||||
@"circle-stroke-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.circleStrokeOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.circleStrokeOpacity = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a constant value expression should update circle-stroke-opacity.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeOpacity, constantExpression,
|
||||
@"circleStrokeOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleStrokeOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a camera expression should update circle-stroke-opacity.");
|
||||
@@ -521,8 +560,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleStrokeOpacity = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a data expression should update circle-stroke-opacity.");
|
||||
@@ -533,11 +576,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleStrokeOpacity = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue,
|
||||
@"Setting circleStrokeOpacity to a camera-data expression should update circle-stroke-opacity.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -566,23 +611,24 @@
|
||||
@"circle-stroke-width should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.circleStrokeWidth;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.circleStrokeWidth = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a constant value expression should update circle-stroke-width.");
|
||||
XCTAssertEqualObjects(layer.circleStrokeWidth, constantExpression,
|
||||
@"circleStrokeWidth should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleStrokeWidth = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a camera expression should update circle-stroke-width.");
|
||||
@@ -592,8 +638,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.circleStrokeWidth = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a data expression should update circle-stroke-width.");
|
||||
@@ -604,11 +654,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.circleStrokeWidth = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue,
|
||||
@"Setting circleStrokeWidth to a camera-data expression should update circle-stroke-width.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -655,11 +707,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleTranslation = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = {{
|
||||
{ -INFINITY, { 1, 1 } },
|
||||
{ 18, { 1, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>>(
|
||||
step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleTranslate(), propertyValue,
|
||||
@"Setting circleTranslation to a camera expression should update circle-translate.");
|
||||
@@ -698,11 +751,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.circleTranslationAnchor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::TranslateAnchorType::Viewport },
|
||||
{ 18, mbgl::style::TranslateAnchorType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getCircleTranslateAnchor(), propertyValue,
|
||||
@"Setting circleTranslationAnchor to a camera expression should update circle-translate-anchor.");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLFillExtrusionLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -54,23 +55,24 @@
|
||||
@"fill-extrusion-base should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.fillExtrusionBase;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.fillExtrusionBase = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
|
||||
@"Setting fillExtrusionBase to a constant value expression should update fill-extrusion-base.");
|
||||
XCTAssertEqualObjects(layer.fillExtrusionBase, constantExpression,
|
||||
@"fillExtrusionBase should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionBase = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
|
||||
@"Setting fillExtrusionBase to a camera expression should update fill-extrusion-base.");
|
||||
@@ -80,8 +82,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.fillExtrusionBase = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
|
||||
@"Setting fillExtrusionBase to a data expression should update fill-extrusion-base.");
|
||||
@@ -92,11 +98,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.fillExtrusionBase = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue,
|
||||
@"Setting fillExtrusionBase to a camera-data expression should update fill-extrusion-base.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -137,11 +145,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
|
||||
@"Setting fillExtrusionColor to a camera expression should update fill-extrusion-color.");
|
||||
@@ -151,8 +160,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.fillExtrusionColor = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
|
||||
@"Setting fillExtrusionColor to a data expression should update fill-extrusion-color.");
|
||||
@@ -163,11 +176,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.fillExtrusionColor = functionExpression;
|
||||
|
||||
std::map<float, mbgl::Color> innerStops { {18, { 1, 0, 0, 1 }} };
|
||||
mbgl::style::CompositeExponentialStops<mbgl::Color> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue,
|
||||
@"Setting fillExtrusionColor to a camera-data expression should update fill-extrusion-color.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -196,23 +211,24 @@
|
||||
@"fill-extrusion-height should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.fillExtrusionHeight;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.fillExtrusionHeight = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
|
||||
@"Setting fillExtrusionHeight to a constant value expression should update fill-extrusion-height.");
|
||||
XCTAssertEqualObjects(layer.fillExtrusionHeight, constantExpression,
|
||||
@"fillExtrusionHeight should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionHeight = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
|
||||
@"Setting fillExtrusionHeight to a camera expression should update fill-extrusion-height.");
|
||||
@@ -222,8 +238,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.fillExtrusionHeight = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
|
||||
@"Setting fillExtrusionHeight to a data expression should update fill-extrusion-height.");
|
||||
@@ -234,11 +254,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.fillExtrusionHeight = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue,
|
||||
@"Setting fillExtrusionHeight to a camera-data expression should update fill-extrusion-height.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -267,23 +289,24 @@
|
||||
@"fill-extrusion-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.fillExtrusionOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.fillExtrusionOpacity = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionOpacity(), propertyValue,
|
||||
@"Setting fillExtrusionOpacity to a constant value expression should update fill-extrusion-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillExtrusionOpacity, constantExpression,
|
||||
@"fillExtrusionOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionOpacity(), propertyValue,
|
||||
@"Setting fillExtrusionOpacity to a camera expression should update fill-extrusion-opacity.");
|
||||
@@ -331,11 +354,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionPattern = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = {{
|
||||
{ -INFINITY, "Fill Extrusion Pattern" },
|
||||
{ 18, "Fill Extrusion Pattern" },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::string>(
|
||||
step(zoom(), literal("Fill Extrusion Pattern"), 18.0, literal("Fill Extrusion Pattern"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionPattern(), propertyValue,
|
||||
@"Setting fillExtrusionPattern to a camera expression should update fill-extrusion-pattern.");
|
||||
@@ -389,11 +413,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionTranslation = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = {{
|
||||
{ -INFINITY, { 1, 1 } },
|
||||
{ 18, { 1, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>>(
|
||||
step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionTranslate(), propertyValue,
|
||||
@"Setting fillExtrusionTranslation to a camera expression should update fill-extrusion-translate.");
|
||||
@@ -432,11 +457,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillExtrusionTranslationAnchor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::TranslateAnchorType::Viewport },
|
||||
{ 18, mbgl::style::TranslateAnchorType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillExtrusionTranslateAnchor(), propertyValue,
|
||||
@"Setting fillExtrusionTranslationAnchor to a camera expression should update fill-extrusion-translate-anchor.");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/fill_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLFillLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -66,11 +67,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillAntialiased = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<bool> intervalStops = {{
|
||||
{ -INFINITY, false },
|
||||
{ 18, false },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<bool> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<bool>(
|
||||
step(zoom(), literal(false), 18.0, literal(false))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillAntialias(), propertyValue,
|
||||
@"Setting fillAntialiased to a camera expression should update fill-antialias.");
|
||||
@@ -109,11 +111,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a camera expression should update fill-color.");
|
||||
@@ -123,8 +126,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.fillColor = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a data expression should update fill-color.");
|
||||
@@ -135,11 +142,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.fillColor = functionExpression;
|
||||
|
||||
std::map<float, mbgl::Color> innerStops { {18, { 1, 0, 0, 1 }} };
|
||||
mbgl::style::CompositeExponentialStops<mbgl::Color> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillColor(), propertyValue,
|
||||
@"Setting fillColor to a camera-data expression should update fill-color.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -168,23 +177,24 @@
|
||||
@"fill-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.fillOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.fillOpacity = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a constant value expression should update fill-opacity.");
|
||||
XCTAssertEqualObjects(layer.fillOpacity, constantExpression,
|
||||
@"fillOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a camera expression should update fill-opacity.");
|
||||
@@ -194,8 +204,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.fillOpacity = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a data expression should update fill-opacity.");
|
||||
@@ -206,11 +220,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.fillOpacity = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue,
|
||||
@"Setting fillOpacity to a camera-data expression should update fill-opacity.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -251,11 +267,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillOutlineColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a camera expression should update fill-outline-color.");
|
||||
@@ -265,8 +282,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.fillOutlineColor = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a data expression should update fill-outline-color.");
|
||||
@@ -277,11 +298,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.fillOutlineColor = functionExpression;
|
||||
|
||||
std::map<float, mbgl::Color> innerStops { {18, { 1, 0, 0, 1 }} };
|
||||
mbgl::style::CompositeExponentialStops<mbgl::Color> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue,
|
||||
@"Setting fillOutlineColor to a camera-data expression should update fill-outline-color.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -322,11 +345,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillPattern = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = {{
|
||||
{ -INFINITY, "Fill Pattern" },
|
||||
{ 18, "Fill Pattern" },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::string>(
|
||||
step(zoom(), literal("Fill Pattern"), 18.0, literal("Fill Pattern"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillPattern(), propertyValue,
|
||||
@"Setting fillPattern to a camera expression should update fill-pattern.");
|
||||
@@ -380,11 +404,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillTranslation = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = {{
|
||||
{ -INFINITY, { 1, 1 } },
|
||||
{ 18, { 1, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>>(
|
||||
step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillTranslate(), propertyValue,
|
||||
@"Setting fillTranslation to a camera expression should update fill-translate.");
|
||||
@@ -423,11 +448,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.fillTranslationAnchor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::TranslateAnchorType::Viewport },
|
||||
{ 18, mbgl::style::TranslateAnchorType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getFillTranslateAnchor(), propertyValue,
|
||||
@"Setting fillTranslationAnchor to a camera expression should update fill-translate-anchor.");
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/heatmap_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLHeatmapLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -54,23 +55,24 @@
|
||||
@"heatmap-intensity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.heatmapIntensity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.heatmapIntensity = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getHeatmapIntensity(), propertyValue,
|
||||
@"Setting heatmapIntensity to a constant value expression should update heatmap-intensity.");
|
||||
XCTAssertEqualObjects(layer.heatmapIntensity, constantExpression,
|
||||
@"heatmapIntensity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.heatmapIntensity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapIntensity(), propertyValue,
|
||||
@"Setting heatmapIntensity to a camera expression should update heatmap-intensity.");
|
||||
@@ -106,23 +108,24 @@
|
||||
@"heatmap-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.heatmapOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.heatmapOpacity = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getHeatmapOpacity(), propertyValue,
|
||||
@"Setting heatmapOpacity to a constant value expression should update heatmap-opacity.");
|
||||
XCTAssertEqualObjects(layer.heatmapOpacity, constantExpression,
|
||||
@"heatmapOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.heatmapOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapOpacity(), propertyValue,
|
||||
@"Setting heatmapOpacity to a camera expression should update heatmap-opacity.");
|
||||
@@ -158,23 +161,24 @@
|
||||
@"heatmap-radius should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.heatmapRadius;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.heatmapRadius = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
|
||||
@"Setting heatmapRadius to a constant value expression should update heatmap-radius.");
|
||||
XCTAssertEqualObjects(layer.heatmapRadius, constantExpression,
|
||||
@"heatmapRadius should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.heatmapRadius = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
|
||||
@"Setting heatmapRadius to a camera expression should update heatmap-radius.");
|
||||
@@ -184,8 +188,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.heatmapRadius = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
|
||||
@"Setting heatmapRadius to a data expression should update heatmap-radius.");
|
||||
@@ -196,11 +204,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.heatmapRadius = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue,
|
||||
@"Setting heatmapRadius to a camera-data expression should update heatmap-radius.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -229,23 +239,24 @@
|
||||
@"heatmap-weight should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.heatmapWeight;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.heatmapWeight = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
|
||||
@"Setting heatmapWeight to a constant value expression should update heatmap-weight.");
|
||||
XCTAssertEqualObjects(layer.heatmapWeight, constantExpression,
|
||||
@"heatmapWeight should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.heatmapWeight = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
|
||||
@"Setting heatmapWeight to a camera expression should update heatmap-weight.");
|
||||
@@ -255,8 +266,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.heatmapWeight = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
|
||||
@"Setting heatmapWeight to a data expression should update heatmap-weight.");
|
||||
@@ -267,11 +282,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.heatmapWeight = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue,
|
||||
@"Setting heatmapWeight to a camera-data expression should update heatmap-weight.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/hillshade_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLHillshadeLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -48,11 +49,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.hillshadeAccentColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHillshadeAccentColor(), propertyValue,
|
||||
@"Setting hillshadeAccentColor to a camera expression should update hillshade-accent-color.");
|
||||
@@ -88,23 +90,24 @@
|
||||
@"hillshade-exaggeration should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.hillshadeExaggeration;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.hillshadeExaggeration = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getHillshadeExaggeration(), propertyValue,
|
||||
@"Setting hillshadeExaggeration to a constant value expression should update hillshade-exaggeration.");
|
||||
XCTAssertEqualObjects(layer.hillshadeExaggeration, constantExpression,
|
||||
@"hillshadeExaggeration should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.hillshadeExaggeration = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHillshadeExaggeration(), propertyValue,
|
||||
@"Setting hillshadeExaggeration to a camera expression should update hillshade-exaggeration.");
|
||||
@@ -152,11 +155,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.hillshadeHighlightColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHillshadeHighlightColor(), propertyValue,
|
||||
@"Setting hillshadeHighlightColor to a camera expression should update hillshade-highlight-color.");
|
||||
@@ -204,11 +208,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.hillshadeIlluminationAnchor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::HillshadeIlluminationAnchorType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::HillshadeIlluminationAnchorType::Viewport },
|
||||
{ 18, mbgl::style::HillshadeIlluminationAnchorType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::HillshadeIlluminationAnchorType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::HillshadeIlluminationAnchorType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHillshadeIlluminationAnchor(), propertyValue,
|
||||
@"Setting hillshadeIlluminationAnchor to a camera expression should update hillshade-illumination-anchor.");
|
||||
@@ -235,23 +240,24 @@
|
||||
@"hillshade-illumination-direction should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.hillshadeIlluminationDirection;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.hillshadeIlluminationDirection = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getHillshadeIlluminationDirection(), propertyValue,
|
||||
@"Setting hillshadeIlluminationDirection to a constant value expression should update hillshade-illumination-direction.");
|
||||
XCTAssertEqualObjects(layer.hillshadeIlluminationDirection, constantExpression,
|
||||
@"hillshadeIlluminationDirection should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.hillshadeIlluminationDirection = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHillshadeIlluminationDirection(), propertyValue,
|
||||
@"Setting hillshadeIlluminationDirection to a camera expression should update hillshade-illumination-direction.");
|
||||
@@ -290,11 +296,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.hillshadeShadowColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getHillshadeShadowColor(), propertyValue,
|
||||
@"Setting hillshadeShadowColor to a camera expression should update hillshade-shadow-color.");
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
XCTAssert(intensityTransition.delay && MGLTimeIntervalFromDuration(*intensityTransition.delay) == defaultTransition.delay);
|
||||
XCTAssert(intensityTransition.duration && MGLTimeIntervalFromDuration(*intensityTransition.duration) == defaultTransition.duration);
|
||||
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
light.setIntensity(propertyValue);
|
||||
light.setIntensityTransition(transitionOptions);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/line_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLLineLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -66,11 +67,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineCap = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::LineCapType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::LineCapType::Square },
|
||||
{ 18, mbgl::style::LineCapType::Square },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::LineCapType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::LineCapType>(
|
||||
step(zoom(), literal("square"), 18.0, literal("square"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineCap(), propertyValue,
|
||||
@"Setting lineCap to a camera expression should update line-cap.");
|
||||
@@ -109,11 +111,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineJoin = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::LineJoinType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::LineJoinType::Miter },
|
||||
{ 18, mbgl::style::LineJoinType::Miter },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::LineJoinType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::LineJoinType>(
|
||||
step(zoom(), literal("miter"), 18.0, literal("miter"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineJoin(), propertyValue,
|
||||
@"Setting lineJoin to a camera expression should update line-join.");
|
||||
@@ -134,23 +137,24 @@
|
||||
@"line-miter-limit should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineMiterLimit;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineMiterLimit = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue,
|
||||
@"Setting lineMiterLimit to a constant value expression should update line-miter-limit.");
|
||||
XCTAssertEqualObjects(layer.lineMiterLimit, constantExpression,
|
||||
@"lineMiterLimit should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineMiterLimit = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineMiterLimit(), propertyValue,
|
||||
@"Setting lineMiterLimit to a camera expression should update line-miter-limit.");
|
||||
@@ -177,23 +181,24 @@
|
||||
@"line-round-limit should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineRoundLimit;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineRoundLimit = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue,
|
||||
@"Setting lineRoundLimit to a constant value expression should update line-round-limit.");
|
||||
XCTAssertEqualObjects(layer.lineRoundLimit, constantExpression,
|
||||
@"lineRoundLimit should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineRoundLimit = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineRoundLimit(), propertyValue,
|
||||
@"Setting lineRoundLimit to a camera expression should update line-round-limit.");
|
||||
@@ -220,23 +225,24 @@
|
||||
@"line-blur should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineBlur;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineBlur = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a constant value expression should update line-blur.");
|
||||
XCTAssertEqualObjects(layer.lineBlur, constantExpression,
|
||||
@"lineBlur should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineBlur = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a camera expression should update line-blur.");
|
||||
@@ -246,8 +252,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.lineBlur = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a data expression should update line-blur.");
|
||||
@@ -258,11 +268,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.lineBlur = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineBlur(), propertyValue,
|
||||
@"Setting lineBlur to a camera-data expression should update line-blur.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -303,11 +315,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineColor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::Color> intervalStops = {{
|
||||
{ -INFINITY, { 1, 0, 0, 1 } },
|
||||
{ 18, { 1, 0, 0, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::Color>(
|
||||
step(zoom(), literal(mbgl::Color(1, 0, 0, 1)), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a camera expression should update line-color.");
|
||||
@@ -317,8 +330,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.lineColor = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<mbgl::Color> exponentialStops = { {{18, { 1, 0, 0, 1 }}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<mbgl::Color>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a data expression should update line-color.");
|
||||
@@ -329,11 +346,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.lineColor = functionExpression;
|
||||
|
||||
std::map<float, mbgl::Color> innerStops { {18, { 1, 0, 0, 1 }} };
|
||||
mbgl::style::CompositeExponentialStops<mbgl::Color> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<mbgl::Color>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1))))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineColor(), propertyValue,
|
||||
@"Setting lineColor to a camera-data expression should update line-color.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -374,11 +393,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineDashPattern = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::vector<float>> intervalStops = {{
|
||||
{ -INFINITY, {1, 2} },
|
||||
{ 18, {1, 2} },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::vector<float>> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::vector<float>>(
|
||||
step(zoom(), literal({1, 2}), 18.0, literal({1, 2}))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineDasharray(), propertyValue,
|
||||
@"Setting lineDashPattern to a camera expression should update line-dasharray.");
|
||||
@@ -405,23 +425,24 @@
|
||||
@"line-gap-width should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineGapWidth;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineGapWidth = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a constant value expression should update line-gap-width.");
|
||||
XCTAssertEqualObjects(layer.lineGapWidth, constantExpression,
|
||||
@"lineGapWidth should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineGapWidth = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a camera expression should update line-gap-width.");
|
||||
@@ -431,8 +452,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.lineGapWidth = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a data expression should update line-gap-width.");
|
||||
@@ -443,11 +468,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.lineGapWidth = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue,
|
||||
@"Setting lineGapWidth to a camera-data expression should update line-gap-width.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -476,23 +503,24 @@
|
||||
@"line-offset should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineOffset;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineOffset = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a constant value expression should update line-offset.");
|
||||
XCTAssertEqualObjects(layer.lineOffset, constantExpression,
|
||||
@"lineOffset should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineOffset = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a camera expression should update line-offset.");
|
||||
@@ -502,8 +530,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.lineOffset = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a data expression should update line-offset.");
|
||||
@@ -514,11 +546,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.lineOffset = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOffset(), propertyValue,
|
||||
@"Setting lineOffset to a camera-data expression should update line-offset.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -547,23 +581,24 @@
|
||||
@"line-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineOpacity = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a constant value expression should update line-opacity.");
|
||||
XCTAssertEqualObjects(layer.lineOpacity, constantExpression,
|
||||
@"lineOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a camera expression should update line-opacity.");
|
||||
@@ -573,8 +608,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.lineOpacity = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a data expression should update line-opacity.");
|
||||
@@ -585,11 +624,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.lineOpacity = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue,
|
||||
@"Setting lineOpacity to a camera-data expression should update line-opacity.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
@@ -630,11 +671,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.linePattern = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::string> intervalStops = {{
|
||||
{ -INFINITY, "Line Pattern" },
|
||||
{ 18, "Line Pattern" },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::string> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::string>(
|
||||
step(zoom(), literal("Line Pattern"), 18.0, literal("Line Pattern"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLinePattern(), propertyValue,
|
||||
@"Setting linePattern to a camera expression should update line-pattern.");
|
||||
@@ -688,11 +730,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineTranslation = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<std::array<float, 2>> intervalStops = {{
|
||||
{ -INFINITY, { 1, 1 } },
|
||||
{ 18, { 1, 1 } },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<std::array<float, 2>>(
|
||||
step(zoom(), literal({ 1, 1 }), 18.0, literal({ 1, 1 }))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineTranslate(), propertyValue,
|
||||
@"Setting lineTranslation to a camera expression should update line-translate.");
|
||||
@@ -731,11 +774,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineTranslationAnchor = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::TranslateAnchorType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::TranslateAnchorType::Viewport },
|
||||
{ 18, mbgl::style::TranslateAnchorType::Viewport },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::TranslateAnchorType>(
|
||||
step(zoom(), literal("viewport"), 18.0, literal("viewport"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineTranslateAnchor(), propertyValue,
|
||||
@"Setting lineTranslationAnchor to a camera expression should update line-translate-anchor.");
|
||||
@@ -762,23 +806,24 @@
|
||||
@"line-width should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.lineWidth;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.lineWidth = constantExpression;
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::DataDrivenPropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
|
||||
@"Setting lineWidth to a constant value expression should update line-width.");
|
||||
XCTAssertEqualObjects(layer.lineWidth, constantExpression,
|
||||
@"lineWidth should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.lineWidth = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
|
||||
@"Setting lineWidth to a camera expression should update line-width.");
|
||||
@@ -788,8 +833,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.lineWidth = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<float> exponentialStops = { {{18, 0xff}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<float> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<float>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
|
||||
@"Setting lineWidth to a data expression should update line-width.");
|
||||
@@ -800,11 +849,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.lineWidth = functionExpression;
|
||||
|
||||
std::map<float, float> innerStops { {18, 0xff} };
|
||||
mbgl::style::CompositeExponentialStops<float> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<float> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<float>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getLineWidth(), propertyValue,
|
||||
@"Setting lineWidth to a camera-data expression should update line-width.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <mbgl/style/layers/raster_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGLRasterLayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -36,23 +37,24 @@
|
||||
@"raster-brightness-max should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.maximumRasterBrightness;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.maximumRasterBrightness = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue,
|
||||
@"Setting maximumRasterBrightness to a constant value expression should update raster-brightness-max.");
|
||||
XCTAssertEqualObjects(layer.maximumRasterBrightness, constantExpression,
|
||||
@"maximumRasterBrightness should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.maximumRasterBrightness = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMax(), propertyValue,
|
||||
@"Setting maximumRasterBrightness to a camera expression should update raster-brightness-max.");
|
||||
@@ -79,23 +81,24 @@
|
||||
@"raster-brightness-min should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.minimumRasterBrightness;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.minimumRasterBrightness = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue,
|
||||
@"Setting minimumRasterBrightness to a constant value expression should update raster-brightness-min.");
|
||||
XCTAssertEqualObjects(layer.minimumRasterBrightness, constantExpression,
|
||||
@"minimumRasterBrightness should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.minimumRasterBrightness = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterBrightnessMin(), propertyValue,
|
||||
@"Setting minimumRasterBrightness to a camera expression should update raster-brightness-min.");
|
||||
@@ -122,23 +125,24 @@
|
||||
@"raster-contrast should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.rasterContrast;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.rasterContrast = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue,
|
||||
@"Setting rasterContrast to a constant value expression should update raster-contrast.");
|
||||
XCTAssertEqualObjects(layer.rasterContrast, constantExpression,
|
||||
@"rasterContrast should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.rasterContrast = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterContrast(), propertyValue,
|
||||
@"Setting rasterContrast to a camera expression should update raster-contrast.");
|
||||
@@ -174,23 +178,24 @@
|
||||
@"raster-fade-duration should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.rasterFadeDuration;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.rasterFadeDuration = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue,
|
||||
@"Setting rasterFadeDuration to a constant value expression should update raster-fade-duration.");
|
||||
XCTAssertEqualObjects(layer.rasterFadeDuration, constantExpression,
|
||||
@"rasterFadeDuration should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.rasterFadeDuration = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterFadeDuration(), propertyValue,
|
||||
@"Setting rasterFadeDuration to a camera expression should update raster-fade-duration.");
|
||||
@@ -217,23 +222,24 @@
|
||||
@"raster-hue-rotate should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.rasterHueRotation;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.rasterHueRotation = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue,
|
||||
@"Setting rasterHueRotation to a constant value expression should update raster-hue-rotate.");
|
||||
XCTAssertEqualObjects(layer.rasterHueRotation, constantExpression,
|
||||
@"rasterHueRotation should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.rasterHueRotation = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterHueRotate(), propertyValue,
|
||||
@"Setting rasterHueRotation to a camera expression should update raster-hue-rotate.");
|
||||
@@ -260,23 +266,24 @@
|
||||
@"raster-opacity should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.rasterOpacity;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.rasterOpacity = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue,
|
||||
@"Setting rasterOpacity to a constant value expression should update raster-opacity.");
|
||||
XCTAssertEqualObjects(layer.rasterOpacity, constantExpression,
|
||||
@"rasterOpacity should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.rasterOpacity = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterOpacity(), propertyValue,
|
||||
@"Setting rasterOpacity to a camera expression should update raster-opacity.");
|
||||
@@ -324,11 +331,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.rasterResamplingMode = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<mbgl::style::RasterResamplingType> intervalStops = {{
|
||||
{ -INFINITY, mbgl::style::RasterResamplingType::Nearest },
|
||||
{ 18, mbgl::style::RasterResamplingType::Nearest },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::RasterResamplingType> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<mbgl::style::RasterResamplingType>(
|
||||
step(zoom(), literal("nearest"), 18.0, literal("nearest"))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterResampling(), propertyValue,
|
||||
@"Setting rasterResamplingMode to a camera expression should update raster-resampling.");
|
||||
@@ -355,23 +363,24 @@
|
||||
@"raster-saturation should be unset initially.");
|
||||
NSExpression *defaultExpression = layer.rasterSaturation;
|
||||
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
layer.rasterSaturation = constantExpression;
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 0xff };
|
||||
mbgl::style::PropertyValue<float> propertyValue = { 1.0 };
|
||||
XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue,
|
||||
@"Setting rasterSaturation to a constant value expression should update raster-saturation.");
|
||||
XCTAssertEqualObjects(layer.rasterSaturation, constantExpression,
|
||||
@"rasterSaturation should round-trip constant value expressions.");
|
||||
|
||||
constantExpression = [NSExpression expressionWithFormat:@"0xff"];
|
||||
constantExpression = [NSExpression expressionWithFormat:@"1"];
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.rasterSaturation = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<float> intervalStops = {{
|
||||
{ -INFINITY, 0xff },
|
||||
{ 18, 0xff },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<float> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<float>(
|
||||
step(zoom(), literal(1.0), 18.0, literal(1.0))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->getRasterSaturation(), propertyValue,
|
||||
@"Setting rasterSaturation to a camera expression should update raster-saturation.");
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
|
||||
#include <mbgl/style/transition_options.hpp>
|
||||
#include <mbgl/style/expression/dsl.hpp>
|
||||
|
||||
@interface MGL<%- camelize(type) %>LayerTests : MGLStyleLayerTests
|
||||
@end
|
||||
@@ -83,11 +84,12 @@
|
||||
NSExpression *functionExpression = [NSExpression expressionWithFormat:@"mgl_step:from:stops:($zoomLevel, %@, %@)", constantExpression, @{@18: constantExpression}];
|
||||
layer.<%- objCName(property) %> = functionExpression;
|
||||
|
||||
mbgl::style::IntervalStops<<%- mbglType(property) %>> intervalStops = {{
|
||||
{ -INFINITY, <%- mbglTestValue(property, type) %> },
|
||||
{ 18, <%- mbglTestValue(property, type) %> },
|
||||
}};
|
||||
propertyValue = mbgl::style::CameraFunction<<%- mbglType(property) %>> { intervalStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CameraFunction<<%- mbglType(property) %>>(
|
||||
step(zoom(), literal(<%- mbglExpressionTestValue(property, type) %>), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a camera expression should update <%- originalPropertyName(property) %>.");
|
||||
@@ -98,8 +100,12 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:(keyName, 'linear', nil, %@)", @{@18: constantExpression}];
|
||||
layer.<%- objCName(property) %> = functionExpression;
|
||||
|
||||
mbgl::style::ExponentialStops<<%- mbglType(property) %>> exponentialStops = { {{18, <%- mbglTestValue(property, type) %>}}, 1.0 };
|
||||
propertyValue = mbgl::style::SourceFunction<<%- mbglType(property) %>> { "keyName", exponentialStops };
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::SourceFunction<<%- mbglType(property) %>>(
|
||||
interpolate(linear(), number(get("keyName")), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a data expression should update <%- originalPropertyName(property) %>.");
|
||||
@@ -110,11 +116,13 @@
|
||||
functionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: functionExpression}];
|
||||
layer.<%- objCName(property) %> = functionExpression;
|
||||
|
||||
std::map<float, <%- mbglType(property) %>> innerStops { {18, <%- mbglTestValue(property, type) %>} };
|
||||
mbgl::style::CompositeExponentialStops<<%- mbglType(property) %>> compositeStops { { {10.0, innerStops} }, 1.0 };
|
||||
|
||||
propertyValue = mbgl::style::CompositeFunction<<%- mbglType(property) %>> { "keyName", compositeStops };
|
||||
|
||||
{
|
||||
using namespace mbgl::style::expression::dsl;
|
||||
propertyValue = mbgl::style::CompositeFunction<<%- mbglType(property) %>>(
|
||||
interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(<%- mbglExpressionTestValue(property, type) %>)))
|
||||
);
|
||||
}
|
||||
|
||||
XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue,
|
||||
@"Setting <%- objCName(property) %> to a camera-data expression should update <%- originalPropertyName(property) %>.");
|
||||
pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/style/expression/assertion.hpp>
|
||||
#include <mbgl/style/expression/coercion.hpp>
|
||||
#include <mbgl/style/expression/equals.hpp>
|
||||
#include <mbgl/style/expression/step.hpp>
|
||||
#include <mbgl/style/expression/interpolate.hpp>
|
||||
#include <mbgl/style/expression/compound_expression.hpp>
|
||||
#include <mbgl/util/ignore.hpp>
|
||||
@@ -35,6 +36,22 @@ std::unique_ptr<Expression> literal(Value value) {
|
||||
return std::make_unique<Literal>(value);
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> literal(std::initializer_list<double> value) {
|
||||
std::vector<Value> values;
|
||||
for (auto i : value) {
|
||||
values.push_back(i);
|
||||
}
|
||||
return literal(values);
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> literal(std::initializer_list<const char *> value) {
|
||||
std::vector<Value> values;
|
||||
for (auto i : value) {
|
||||
values.push_back(std::string(i));
|
||||
}
|
||||
return literal(values);
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> number(std::unique_ptr<Expression> value) {
|
||||
return std::make_unique<Assertion>(type::Number, vec(std::move(value)));
|
||||
}
|
||||
@@ -87,6 +104,16 @@ std::unique_ptr<Expression> lt(std::unique_ptr<Expression> lhs,
|
||||
return compound("<", std::move(lhs), std::move(rhs));
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> step(std::unique_ptr<Expression> input,
|
||||
std::unique_ptr<Expression> output0,
|
||||
double input1, std::unique_ptr<Expression> output1) {
|
||||
type::Type type = output0->getType();
|
||||
std::map<double, std::unique_ptr<Expression>> stops;
|
||||
stops[-std::numeric_limits<double>::infinity()] = std::move(output0);
|
||||
stops[input1] = std::move(output1);
|
||||
return std::make_unique<Step>(type, std::move(input), std::move(stops));
|
||||
}
|
||||
|
||||
Interpolator linear() {
|
||||
return ExponentialInterpolator(1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user