summaryrefslogtreecommitdiff
path: root/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-06-28 14:58:52 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-06-29 15:38:11 -0700
commit6dfe56510caa87b3e0fdbb8256d13ec955764d53 (patch)
tree0df4859ec90a88d2fca83c18c2aef28924db25ae /platform/darwin/test/MGLHeatmapStyleLayerTests.mm
parent542a4b4501794653b55fd1ffc60cb01348d8fc88 (diff)
downloadqtlocation-mapboxgl-6dfe56510caa87b3e0fdbb8256d13ec955764d53.tar.gz
[darwin] Replace use of *Stops with expressions DSL
Diffstat (limited to 'platform/darwin/test/MGLHeatmapStyleLayerTests.mm')
-rw-r--r--platform/darwin/test/MGLHeatmapStyleLayerTests.mm109
1 files changed, 63 insertions, 46 deletions
diff --git a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
index db15778872..c58cac9af0 100644
--- a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
+++ b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
@@ -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}];