From 9bdd765a02de75851a00ab85223d5d582a104757 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 31 Jul 2018 14:21:47 -0700 Subject: [core] Merge DataDrivenPropertyValue into PropertyValue (#12513) --- benchmark/function/camera_function.benchmark.cpp | 4 +- .../function/composite_function.benchmark.cpp | 12 +- benchmark/function/source_function.benchmark.cpp | 12 +- cmake/core-files.cmake | 2 - include/mbgl/annotation/annotation.hpp | 26 +-- .../style/conversion/color_ramp_property_value.hpp | 2 +- .../conversion/data_driven_property_value.hpp | 78 ------- include/mbgl/style/conversion/property_value.hpp | 25 ++- include/mbgl/style/data_driven_property_value.hpp | 74 ------- include/mbgl/style/layers/background_layer.hpp | 1 - include/mbgl/style/layers/circle_layer.hpp | 43 ++-- include/mbgl/style/layers/fill_extrusion_layer.hpp | 19 +- include/mbgl/style/layers/fill_layer.hpp | 19 +- include/mbgl/style/layers/heatmap_layer.hpp | 13 +- include/mbgl/style/layers/hillshade_layer.hpp | 1 - include/mbgl/style/layers/layer.hpp.ejs | 1 - include/mbgl/style/layers/line_layer.hpp | 43 ++-- include/mbgl/style/layers/raster_layer.hpp | 1 - include/mbgl/style/layers/symbol_layer.hpp | 151 +++++++------- include/mbgl/style/property_value.hpp | 68 +++++-- platform/android/scripts/generate-style-code.js | 3 - .../src/style/conversion/property_value.hpp | 13 -- platform/darwin/src/MGLBackgroundStyleLayer.mm | 6 +- platform/darwin/src/MGLCircleStyleLayer.mm | 22 +- platform/darwin/src/MGLFillExtrusionStyleLayer.mm | 14 +- platform/darwin/src/MGLFillStyleLayer.mm | 14 +- platform/darwin/src/MGLHeatmapStyleLayer.mm | 8 +- platform/darwin/src/MGLHillshadeStyleLayer.mm | 12 +- platform/darwin/src/MGLLight.mm | 26 +-- platform/darwin/src/MGLLight.mm.ejs | 16 +- platform/darwin/src/MGLLineStyleLayer.mm | 28 +-- platform/darwin/src/MGLRasterStyleLayer.mm | 16 +- platform/darwin/src/MGLStyleLayer.mm.ejs | 10 +- platform/darwin/src/MGLStyleValue_Private.h | 47 ++--- platform/darwin/src/MGLSymbolStyleLayer.mm | 104 +++++----- platform/darwin/test/MGLCircleStyleLayerTests.mm | 28 +-- .../darwin/test/MGLFillExtrusionStyleLayerTests.mm | 12 +- platform/darwin/test/MGLFillStyleLayerTests.mm | 12 +- platform/darwin/test/MGLHeatmapStyleLayerTests.mm | 8 +- platform/darwin/test/MGLLineStyleLayerTests.mm | 26 +-- platform/darwin/test/MGLStyleLayerTests.mm.ejs | 6 +- platform/darwin/test/MGLSymbolStyleLayerTests.mm | 86 ++++---- scripts/generate-style-code.js | 3 - src/mbgl/programs/symbol_program.cpp | 10 +- src/mbgl/programs/symbol_program.hpp | 36 ++-- src/mbgl/renderer/buckets/symbol_bucket.cpp | 20 +- src/mbgl/renderer/buckets/symbol_bucket.hpp | 20 +- .../style/conversion/color_ramp_property_value.cpp | 2 +- src/mbgl/style/conversion/light.cpp | 8 +- .../style/conversion/make_property_setters.hpp | 224 ++++++++++----------- .../style/conversion/make_property_setters.hpp.ejs | 4 +- src/mbgl/style/conversion/property_setter.hpp | 5 +- src/mbgl/style/conversion/stringify.hpp | 14 -- src/mbgl/style/layers/circle_layer.cpp | 42 ++-- src/mbgl/style/layers/fill_extrusion_layer.cpp | 18 +- src/mbgl/style/layers/fill_layer.cpp | 18 +- src/mbgl/style/layers/heatmap_layer.cpp | 12 +- src/mbgl/style/layers/line_layer.cpp | 42 ++-- src/mbgl/style/layers/symbol_layer.cpp | 150 +++++++------- src/mbgl/style/layout_property.hpp | 3 +- src/mbgl/style/paint_property.hpp | 7 +- test/style/conversion/function.test.cpp | 7 +- test/style/conversion/property_value.test.cpp | 2 +- test/style/properties.test.cpp | 24 +-- 64 files changed, 802 insertions(+), 981 deletions(-) delete mode 100644 include/mbgl/style/conversion/data_driven_property_value.hpp delete mode 100644 include/mbgl/style/data_driven_property_value.hpp diff --git a/benchmark/function/camera_function.benchmark.cpp b/benchmark/function/camera_function.benchmark.cpp index 52b6bc9f08..51d2e22293 100644 --- a/benchmark/function/camera_function.benchmark.cpp +++ b/benchmark/function/camera_function.benchmark.cpp @@ -27,7 +27,7 @@ static void Parse_CameraFunction(benchmark::State& state) { state.PauseTiming(); auto doc = createFunctionJSON(stopCount); state.ResumeTiming(); - optional> result = conversion::convertJSON>(doc, error); + optional> result = conversion::convertJSON>(doc, error, false, false); if (!result) { state.SkipWithError(error.message.c_str()); } @@ -39,7 +39,7 @@ static void Evaluate_CameraFunction(benchmark::State& state) { size_t stopCount = state.range(0); auto doc = createFunctionJSON(stopCount); conversion::Error error; - optional> function = conversion::convertJSON>(doc, error); + optional> function = conversion::convertJSON>(doc, error, false, false); if (!function) { state.SkipWithError(error.message.c_str()); } diff --git a/benchmark/function/composite_function.benchmark.cpp b/benchmark/function/composite_function.benchmark.cpp index d495a518ca..f16254641f 100644 --- a/benchmark/function/composite_function.benchmark.cpp +++ b/benchmark/function/composite_function.benchmark.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include using namespace mbgl; using namespace mbgl::style; @@ -27,13 +27,13 @@ static std::string createFunctionJSON(size_t stopCount) { static void Parse_CompositeFunction(benchmark::State& state) { size_t stopCount = state.range(0); - + while (state.KeepRunning()) { conversion::Error error; state.PauseTiming(); auto doc = createFunctionJSON(stopCount); state.ResumeTiming(); - optional> result = conversion::convertJSON>(doc, error, false); + optional> result = conversion::convertJSON>(doc, error, true, false); if (!result) { state.SkipWithError(error.message.c_str()); } @@ -45,16 +45,16 @@ static void Evaluate_CompositeFunction(benchmark::State& state) { size_t stopCount = state.range(0); auto doc = createFunctionJSON(stopCount); conversion::Error error; - optional> function = conversion::convertJSON>(doc, error, false); + optional> function = conversion::convertJSON>(doc, error, true, false); if (!function) { state.SkipWithError(error.message.c_str()); } - + while(state.KeepRunning()) { float z = 24.0f * static_cast(rand() % 100) / 100; function->asExpression().evaluate(z, StubGeometryTileFeature(PropertyMap { { "x", static_cast(rand() % 100) } }), -1.0f); } - + state.SetLabel(std::to_string(stopCount).c_str()); } diff --git a/benchmark/function/source_function.benchmark.cpp b/benchmark/function/source_function.benchmark.cpp index a5d2f95487..2164b2a418 100644 --- a/benchmark/function/source_function.benchmark.cpp +++ b/benchmark/function/source_function.benchmark.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include using namespace mbgl; using namespace mbgl::style; @@ -22,13 +22,13 @@ static std::string createFunctionJSON(size_t stopCount) { static void Parse_SourceFunction(benchmark::State& state) { size_t stopCount = state.range(0); - + while (state.KeepRunning()) { conversion::Error error; state.PauseTiming(); auto doc = createFunctionJSON(stopCount); state.ResumeTiming(); - optional> result = conversion::convertJSON>(doc, error, false); + optional> result = conversion::convertJSON>(doc, error, true, false); if (!result) { state.SkipWithError(error.message.c_str()); } @@ -40,15 +40,15 @@ static void Evaluate_SourceFunction(benchmark::State& state) { size_t stopCount = state.range(0); auto doc = createFunctionJSON(stopCount); conversion::Error error; - optional> function = conversion::convertJSON>(doc, error, false); + optional> function = conversion::convertJSON>(doc, error, true, false); if (!function) { state.SkipWithError(error.message.c_str()); } - + while(state.KeepRunning()) { function->asExpression().evaluate(StubGeometryTileFeature(PropertyMap { { "x", static_cast(rand() % 100) } }), -1.0f); } - + state.SetLabel(std::to_string(stopCount).c_str()); } diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake index f2e26a9a7e..44aff682fc 100644 --- a/cmake/core-files.cmake +++ b/cmake/core-files.cmake @@ -363,7 +363,6 @@ set(MBGL_CORE_FILES # style include/mbgl/style/color_ramp_property_value.hpp include/mbgl/style/conversion.hpp - include/mbgl/style/data_driven_property_value.hpp include/mbgl/style/filter.hpp include/mbgl/style/image.hpp include/mbgl/style/layer.hpp @@ -413,7 +412,6 @@ set(MBGL_CORE_FILES include/mbgl/style/conversion/constant.hpp include/mbgl/style/conversion/coordinate.hpp include/mbgl/style/conversion/custom_geometry_source_options.hpp - include/mbgl/style/conversion/data_driven_property_value.hpp include/mbgl/style/conversion/filter.hpp include/mbgl/style/conversion/function.hpp include/mbgl/style/conversion/geojson.hpp diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp index bbe479b5ba..8c099141c4 100644 --- a/include/mbgl/annotation/annotation.hpp +++ b/include/mbgl/annotation/annotation.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -34,35 +34,35 @@ using ShapeAnnotationGeometry = variant< class LineAnnotation { public: LineAnnotation(ShapeAnnotationGeometry geometry_, - style::DataDrivenPropertyValue opacity_ = 1.0f, - style::DataDrivenPropertyValue width_ = 1.0f, - style::DataDrivenPropertyValue color_ = Color::black()) + style::PropertyValue opacity_ = 1.0f, + style::PropertyValue width_ = 1.0f, + style::PropertyValue color_ = Color::black()) : geometry(std::move(geometry_)), opacity(std::move(opacity_)), width(std::move(width_)), color(std::move(color_)) {} ShapeAnnotationGeometry geometry; - style::DataDrivenPropertyValue opacity; - style::DataDrivenPropertyValue width; - style::DataDrivenPropertyValue color; + style::PropertyValue opacity; + style::PropertyValue width; + style::PropertyValue color; }; class FillAnnotation { public: FillAnnotation(ShapeAnnotationGeometry geometry_, - style::DataDrivenPropertyValue opacity_ = 1.0f, - style::DataDrivenPropertyValue color_ = Color::black(), - style::DataDrivenPropertyValue outlineColor_ = {}) + style::PropertyValue opacity_ = 1.0f, + style::PropertyValue color_ = Color::black(), + style::PropertyValue outlineColor_ = {}) : geometry(std::move(geometry_)), opacity(std::move(opacity_)), color(std::move(color_)), outlineColor(std::move(outlineColor_)) {} ShapeAnnotationGeometry geometry; - style::DataDrivenPropertyValue opacity; - style::DataDrivenPropertyValue color; - style::DataDrivenPropertyValue outlineColor; + style::PropertyValue opacity; + style::PropertyValue color; + style::PropertyValue outlineColor; }; using Annotation = variant< diff --git a/include/mbgl/style/conversion/color_ramp_property_value.hpp b/include/mbgl/style/conversion/color_ramp_property_value.hpp index 87049b043b..17aa177420 100644 --- a/include/mbgl/style/conversion/color_ramp_property_value.hpp +++ b/include/mbgl/style/conversion/color_ramp_property_value.hpp @@ -9,7 +9,7 @@ namespace conversion { template <> struct Converter { - optional operator()(const Convertible& value, Error& error, bool /* convertTokens */ = false) const; + optional operator()(const Convertible& value, Error& error, bool /* allowDataExpressions */ = false, bool /* convertTokens */ = false) const; }; } // namespace conversion diff --git a/include/mbgl/style/conversion/data_driven_property_value.hpp b/include/mbgl/style/conversion/data_driven_property_value.hpp deleted file mode 100644 index 2d8817ecf4..0000000000 --- a/include/mbgl/style/conversion/data_driven_property_value.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace mbgl { -namespace style { -namespace conversion { - -template -struct Converter> { - optional> operator()(const Convertible& value, Error& error, bool convertTokens) const { - using namespace mbgl::style::expression; - - if (isUndefined(value)) { - return DataDrivenPropertyValue(); - } - - optional> expression; - - if (isExpression(value)) { - ParsingContext ctx(valueTypeToExpressionType()); - ParseResult parsed = ctx.parseLayerPropertyExpression(value); - if (!parsed) { - error.message = ctx.getCombinedErrors(); - return nullopt; - } - expression = PropertyExpression(std::move(*parsed)); - } else if (isObject(value)) { - expression = convertFunctionToExpression(value, error, convertTokens); - } else { - optional constant = convert(value, error); - if (!constant) { - return nullopt; - } - return convertTokens ? maybeConvertTokens(*constant) : DataDrivenPropertyValue(*constant); - } - - if (!expression) { - return nullopt; - } else if (!(*expression).isFeatureConstant() || !(*expression).isZoomConstant()) { - return { std::move(*expression) }; - } else if ((*expression).getExpression().getKind() == Kind::Literal) { - optional constant = fromExpressionValue( - static_cast((*expression).getExpression()).getValue()); - if (!constant) { - return nullopt; - } - return DataDrivenPropertyValue(*constant); - } else { - assert(false); - error.message = "expected a literal expression"; - return nullopt; - } - } - - template - DataDrivenPropertyValue maybeConvertTokens(const S& t) const { - return DataDrivenPropertyValue(t); - }; - - DataDrivenPropertyValue maybeConvertTokens(const std::string& t) const { - return hasTokens(t) - ? DataDrivenPropertyValue(PropertyExpression(convertTokenStringToExpression(t))) - : DataDrivenPropertyValue(t); - } -}; - -} // namespace conversion -} // namespace style -} // namespace mbgl diff --git a/include/mbgl/style/conversion/property_value.hpp b/include/mbgl/style/conversion/property_value.hpp index 4d13144dd7..fa6752867b 100644 --- a/include/mbgl/style/conversion/property_value.hpp +++ b/include/mbgl/style/conversion/property_value.hpp @@ -16,13 +16,9 @@ namespace conversion { template struct Converter> { - optional> operator()(const Convertible& value, Error& error, bool convertTokens = false) const { + optional> operator()(const Convertible& value, Error& error, bool allowDataExpressions, bool convertTokens) const { using namespace mbgl::style::expression; - // Only icon-image and text-field support tokens, and they are both data-driven. - assert(!convertTokens); - (void)convertTokens; - if (isUndefined(value)) { return PropertyValue(); } @@ -38,21 +34,21 @@ struct Converter> { } expression = PropertyExpression(std::move(*parsed)); } else if (isObject(value)) { - expression = convertFunctionToExpression(value, error, false); + expression = convertFunctionToExpression(value, error, convertTokens); } else { optional constant = convert(value, error); if (!constant) { return nullopt; } - return { *constant }; + return convertTokens ? maybeConvertTokens(*constant) : PropertyValue(*constant); } if (!expression) { return nullopt; - } else if (!(*expression).isFeatureConstant()) { + } else if (!allowDataExpressions && !(*expression).isFeatureConstant()) { error.message = "data expressions not supported"; return nullopt; - } else if (!(*expression).isZoomConstant()) { + } else if (!(*expression).isFeatureConstant() || !(*expression).isZoomConstant()) { return { std::move(*expression) }; } else if ((*expression).getExpression().getKind() == Kind::Literal) { optional constant = fromExpressionValue( @@ -67,6 +63,17 @@ struct Converter> { return nullopt; } } + + template + PropertyValue maybeConvertTokens(const S& t) const { + return PropertyValue(t); + }; + + PropertyValue maybeConvertTokens(const std::string& t) const { + return hasTokens(t) + ? PropertyValue(PropertyExpression(convertTokenStringToExpression(t))) + : PropertyValue(t); + } }; } // namespace conversion diff --git a/include/mbgl/style/data_driven_property_value.hpp b/include/mbgl/style/data_driven_property_value.hpp deleted file mode 100644 index baea861f62..0000000000 --- a/include/mbgl/style/data_driven_property_value.hpp +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace mbgl { -namespace style { - -template -class DataDrivenPropertyValue { -private: - using Value = variant< - Undefined, - T, - PropertyExpression>; - - Value value; - - friend bool operator==(const DataDrivenPropertyValue& lhs, - const DataDrivenPropertyValue& rhs) { - return lhs.value == rhs.value; - } - - friend bool operator!=(const DataDrivenPropertyValue& lhs, - const DataDrivenPropertyValue& rhs) { - return !(lhs == rhs); - } - -public: - DataDrivenPropertyValue() = default; - DataDrivenPropertyValue( T v) : value(std::move(v)) {} - DataDrivenPropertyValue(PropertyExpression v) : value(std::move(v)) {} - - bool isUndefined() const { - return value.template is(); - } - - bool isDataDriven() const { - return value.match( - [] (const Undefined&) { return false; }, - [] (const T&) { return false; }, - [] (const PropertyExpression& fn) { return !fn.isFeatureConstant(); } - ); - } - - bool isZoomConstant() const { - return value.match( - [] (const Undefined&) { return true; }, - [] (const T&) { return true; }, - [] (const PropertyExpression& fn) { return fn.isZoomConstant(); } - ); - } - - const T & asConstant() const { return value.template get< T >(); } - const PropertyExpression& asExpression() const { return value.template get>(); } - - template - auto match(Ts&&... ts) const { - return value.match(std::forward(ts)...); - } - - template - auto evaluate(const Evaluator& evaluator, TimePoint = {}) const { - return Value::visit(value, evaluator); - } - - bool hasDataDrivenPropertyDifference(const DataDrivenPropertyValue& other) const { - return *this != other && (isDataDriven() || other.isDataDriven()); - } -}; - -} // namespace style -} // namespace mbgl diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp index 903983844f..eab2681fec 100644 --- a/include/mbgl/style/layers/background_layer.hpp +++ b/include/mbgl/style/layers/background_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp index 942dd67503..89ef926221 100644 --- a/include/mbgl/style/layers/circle_layer.hpp +++ b/include/mbgl/style/layers/circle_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -36,27 +35,27 @@ public: // Paint properties - static DataDrivenPropertyValue getDefaultCircleRadius(); - DataDrivenPropertyValue getCircleRadius() const; - void setCircleRadius(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleRadius(); + PropertyValue getCircleRadius() const; + void setCircleRadius(PropertyValue); void setCircleRadiusTransition(const TransitionOptions&); TransitionOptions getCircleRadiusTransition() const; - static DataDrivenPropertyValue getDefaultCircleColor(); - DataDrivenPropertyValue getCircleColor() const; - void setCircleColor(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleColor(); + PropertyValue getCircleColor() const; + void setCircleColor(PropertyValue); void setCircleColorTransition(const TransitionOptions&); TransitionOptions getCircleColorTransition() const; - static DataDrivenPropertyValue getDefaultCircleBlur(); - DataDrivenPropertyValue getCircleBlur() const; - void setCircleBlur(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleBlur(); + PropertyValue getCircleBlur() const; + void setCircleBlur(PropertyValue); void setCircleBlurTransition(const TransitionOptions&); TransitionOptions getCircleBlurTransition() const; - static DataDrivenPropertyValue getDefaultCircleOpacity(); - DataDrivenPropertyValue getCircleOpacity() const; - void setCircleOpacity(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleOpacity(); + PropertyValue getCircleOpacity() const; + void setCircleOpacity(PropertyValue); void setCircleOpacityTransition(const TransitionOptions&); TransitionOptions getCircleOpacityTransition() const; @@ -84,21 +83,21 @@ public: void setCirclePitchAlignmentTransition(const TransitionOptions&); TransitionOptions getCirclePitchAlignmentTransition() const; - static DataDrivenPropertyValue getDefaultCircleStrokeWidth(); - DataDrivenPropertyValue getCircleStrokeWidth() const; - void setCircleStrokeWidth(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleStrokeWidth(); + PropertyValue getCircleStrokeWidth() const; + void setCircleStrokeWidth(PropertyValue); void setCircleStrokeWidthTransition(const TransitionOptions&); TransitionOptions getCircleStrokeWidthTransition() const; - static DataDrivenPropertyValue getDefaultCircleStrokeColor(); - DataDrivenPropertyValue getCircleStrokeColor() const; - void setCircleStrokeColor(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleStrokeColor(); + PropertyValue getCircleStrokeColor() const; + void setCircleStrokeColor(PropertyValue); void setCircleStrokeColorTransition(const TransitionOptions&); TransitionOptions getCircleStrokeColorTransition() const; - static DataDrivenPropertyValue getDefaultCircleStrokeOpacity(); - DataDrivenPropertyValue getCircleStrokeOpacity() const; - void setCircleStrokeOpacity(DataDrivenPropertyValue); + static PropertyValue getDefaultCircleStrokeOpacity(); + PropertyValue getCircleStrokeOpacity() const; + void setCircleStrokeOpacity(PropertyValue); void setCircleStrokeOpacityTransition(const TransitionOptions&); TransitionOptions getCircleStrokeOpacityTransition() const; diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp index e1c54f54ee..742bac8c7e 100644 --- a/include/mbgl/style/layers/fill_extrusion_layer.hpp +++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -42,9 +41,9 @@ public: void setFillExtrusionOpacityTransition(const TransitionOptions&); TransitionOptions getFillExtrusionOpacityTransition() const; - static DataDrivenPropertyValue getDefaultFillExtrusionColor(); - DataDrivenPropertyValue getFillExtrusionColor() const; - void setFillExtrusionColor(DataDrivenPropertyValue); + static PropertyValue getDefaultFillExtrusionColor(); + PropertyValue getFillExtrusionColor() const; + void setFillExtrusionColor(PropertyValue); void setFillExtrusionColorTransition(const TransitionOptions&); TransitionOptions getFillExtrusionColorTransition() const; @@ -66,15 +65,15 @@ public: void setFillExtrusionPatternTransition(const TransitionOptions&); TransitionOptions getFillExtrusionPatternTransition() const; - static DataDrivenPropertyValue getDefaultFillExtrusionHeight(); - DataDrivenPropertyValue getFillExtrusionHeight() const; - void setFillExtrusionHeight(DataDrivenPropertyValue); + static PropertyValue getDefaultFillExtrusionHeight(); + PropertyValue getFillExtrusionHeight() const; + void setFillExtrusionHeight(PropertyValue); void setFillExtrusionHeightTransition(const TransitionOptions&); TransitionOptions getFillExtrusionHeightTransition() const; - static DataDrivenPropertyValue getDefaultFillExtrusionBase(); - DataDrivenPropertyValue getFillExtrusionBase() const; - void setFillExtrusionBase(DataDrivenPropertyValue); + static PropertyValue getDefaultFillExtrusionBase(); + PropertyValue getFillExtrusionBase() const; + void setFillExtrusionBase(PropertyValue); void setFillExtrusionBaseTransition(const TransitionOptions&); TransitionOptions getFillExtrusionBaseTransition() const; diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp index dfbe69d7fe..d0b2a25bfe 100644 --- a/include/mbgl/style/layers/fill_layer.hpp +++ b/include/mbgl/style/layers/fill_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -42,21 +41,21 @@ public: void setFillAntialiasTransition(const TransitionOptions&); TransitionOptions getFillAntialiasTransition() const; - static DataDrivenPropertyValue getDefaultFillOpacity(); - DataDrivenPropertyValue getFillOpacity() const; - void setFillOpacity(DataDrivenPropertyValue); + static PropertyValue getDefaultFillOpacity(); + PropertyValue getFillOpacity() const; + void setFillOpacity(PropertyValue); void setFillOpacityTransition(const TransitionOptions&); TransitionOptions getFillOpacityTransition() const; - static DataDrivenPropertyValue getDefaultFillColor(); - DataDrivenPropertyValue getFillColor() const; - void setFillColor(DataDrivenPropertyValue); + static PropertyValue getDefaultFillColor(); + PropertyValue getFillColor() const; + void setFillColor(PropertyValue); void setFillColorTransition(const TransitionOptions&); TransitionOptions getFillColorTransition() const; - static DataDrivenPropertyValue getDefaultFillOutlineColor(); - DataDrivenPropertyValue getFillOutlineColor() const; - void setFillOutlineColor(DataDrivenPropertyValue); + static PropertyValue getDefaultFillOutlineColor(); + PropertyValue getFillOutlineColor() const; + void setFillOutlineColor(PropertyValue); void setFillOutlineColorTransition(const TransitionOptions&); TransitionOptions getFillOutlineColorTransition() const; diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp index 4c434b2aff..53fd24aa6c 100644 --- a/include/mbgl/style/layers/heatmap_layer.hpp +++ b/include/mbgl/style/layers/heatmap_layer.hpp @@ -6,7 +6,6 @@ #include #include #include -#include #include @@ -37,15 +36,15 @@ public: // Paint properties - static DataDrivenPropertyValue getDefaultHeatmapRadius(); - DataDrivenPropertyValue getHeatmapRadius() const; - void setHeatmapRadius(DataDrivenPropertyValue); + static PropertyValue getDefaultHeatmapRadius(); + PropertyValue getHeatmapRadius() const; + void setHeatmapRadius(PropertyValue); void setHeatmapRadiusTransition(const TransitionOptions&); TransitionOptions getHeatmapRadiusTransition() const; - static DataDrivenPropertyValue getDefaultHeatmapWeight(); - DataDrivenPropertyValue getHeatmapWeight() const; - void setHeatmapWeight(DataDrivenPropertyValue); + static PropertyValue getDefaultHeatmapWeight(); + PropertyValue getHeatmapWeight() const; + void setHeatmapWeight(PropertyValue); void setHeatmapWeightTransition(const TransitionOptions&); TransitionOptions getHeatmapWeightTransition() const; diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp index 35664da46c..214576b120 100644 --- a/include/mbgl/style/layers/hillshade_layer.hpp +++ b/include/mbgl/style/layers/hillshade_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs index e15ff74f17..9d52973af4 100644 --- a/include/mbgl/style/layers/layer.hpp.ejs +++ b/include/mbgl/style/layers/layer.hpp.ejs @@ -13,7 +13,6 @@ #include #include #include -#include #include diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp index 4519296323..26e3b81fc9 100644 --- a/include/mbgl/style/layers/line_layer.hpp +++ b/include/mbgl/style/layers/line_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -42,9 +41,9 @@ public: PropertyValue getLineCap() const; void setLineCap(PropertyValue); - static DataDrivenPropertyValue getDefaultLineJoin(); - DataDrivenPropertyValue getLineJoin() const; - void setLineJoin(DataDrivenPropertyValue); + static PropertyValue getDefaultLineJoin(); + PropertyValue getLineJoin() const; + void setLineJoin(PropertyValue); static PropertyValue getDefaultLineMiterLimit(); PropertyValue getLineMiterLimit() const; @@ -56,15 +55,15 @@ public: // Paint properties - static DataDrivenPropertyValue getDefaultLineOpacity(); - DataDrivenPropertyValue getLineOpacity() const; - void setLineOpacity(DataDrivenPropertyValue); + static PropertyValue getDefaultLineOpacity(); + PropertyValue getLineOpacity() const; + void setLineOpacity(PropertyValue); void setLineOpacityTransition(const TransitionOptions&); TransitionOptions getLineOpacityTransition() const; - static DataDrivenPropertyValue getDefaultLineColor(); - DataDrivenPropertyValue getLineColor() const; - void setLineColor(DataDrivenPropertyValue); + static PropertyValue getDefaultLineColor(); + PropertyValue getLineColor() const; + void setLineColor(PropertyValue); void setLineColorTransition(const TransitionOptions&); TransitionOptions getLineColorTransition() const; @@ -80,27 +79,27 @@ public: void setLineTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getLineTranslateAnchorTransition() const; - static DataDrivenPropertyValue getDefaultLineWidth(); - DataDrivenPropertyValue getLineWidth() const; - void setLineWidth(DataDrivenPropertyValue); + static PropertyValue getDefaultLineWidth(); + PropertyValue getLineWidth() const; + void setLineWidth(PropertyValue); void setLineWidthTransition(const TransitionOptions&); TransitionOptions getLineWidthTransition() const; - static DataDrivenPropertyValue getDefaultLineGapWidth(); - DataDrivenPropertyValue getLineGapWidth() const; - void setLineGapWidth(DataDrivenPropertyValue); + static PropertyValue getDefaultLineGapWidth(); + PropertyValue getLineGapWidth() const; + void setLineGapWidth(PropertyValue); void setLineGapWidthTransition(const TransitionOptions&); TransitionOptions getLineGapWidthTransition() const; - static DataDrivenPropertyValue getDefaultLineOffset(); - DataDrivenPropertyValue getLineOffset() const; - void setLineOffset(DataDrivenPropertyValue); + static PropertyValue getDefaultLineOffset(); + PropertyValue getLineOffset() const; + void setLineOffset(PropertyValue); void setLineOffsetTransition(const TransitionOptions&); TransitionOptions getLineOffsetTransition() const; - static DataDrivenPropertyValue getDefaultLineBlur(); - DataDrivenPropertyValue getLineBlur() const; - void setLineBlur(DataDrivenPropertyValue); + static PropertyValue getDefaultLineBlur(); + PropertyValue getLineBlur() const; + void setLineBlur(PropertyValue); void setLineBlurTransition(const TransitionOptions&); TransitionOptions getLineBlurTransition() const; diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp index 8e7849c27d..c133c23484 100644 --- a/include/mbgl/style/layers/raster_layer.hpp +++ b/include/mbgl/style/layers/raster_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp index f068e2d060..8c0b45d796 100644 --- a/include/mbgl/style/layers/symbol_layer.hpp +++ b/include/mbgl/style/layers/symbol_layer.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include @@ -66,9 +65,9 @@ public: PropertyValue getIconRotationAlignment() const; void setIconRotationAlignment(PropertyValue); - static DataDrivenPropertyValue getDefaultIconSize(); - DataDrivenPropertyValue getIconSize() const; - void setIconSize(DataDrivenPropertyValue); + static PropertyValue getDefaultIconSize(); + PropertyValue getIconSize() const; + void setIconSize(PropertyValue); static PropertyValue getDefaultIconTextFit(); PropertyValue getIconTextFit() const; @@ -78,13 +77,13 @@ public: PropertyValue> getIconTextFitPadding() const; void setIconTextFitPadding(PropertyValue>); - static DataDrivenPropertyValue getDefaultIconImage(); - DataDrivenPropertyValue getIconImage() const; - void setIconImage(DataDrivenPropertyValue); + static PropertyValue getDefaultIconImage(); + PropertyValue getIconImage() const; + void setIconImage(PropertyValue); - static DataDrivenPropertyValue getDefaultIconRotate(); - DataDrivenPropertyValue getIconRotate() const; - void setIconRotate(DataDrivenPropertyValue); + static PropertyValue getDefaultIconRotate(); + PropertyValue getIconRotate() const; + void setIconRotate(PropertyValue); static PropertyValue getDefaultIconPadding(); PropertyValue getIconPadding() const; @@ -94,13 +93,13 @@ public: PropertyValue getIconKeepUpright() const; void setIconKeepUpright(PropertyValue); - static DataDrivenPropertyValue> getDefaultIconOffset(); - DataDrivenPropertyValue> getIconOffset() const; - void setIconOffset(DataDrivenPropertyValue>); + static PropertyValue> getDefaultIconOffset(); + PropertyValue> getIconOffset() const; + void setIconOffset(PropertyValue>); - static DataDrivenPropertyValue getDefaultIconAnchor(); - DataDrivenPropertyValue getIconAnchor() const; - void setIconAnchor(DataDrivenPropertyValue); + static PropertyValue getDefaultIconAnchor(); + PropertyValue getIconAnchor() const; + void setIconAnchor(PropertyValue); static PropertyValue getDefaultIconPitchAlignment(); PropertyValue getIconPitchAlignment() const; @@ -114,45 +113,45 @@ public: PropertyValue getTextRotationAlignment() const; void setTextRotationAlignment(PropertyValue); - static DataDrivenPropertyValue getDefaultTextField(); - DataDrivenPropertyValue getTextField() const; - void setTextField(DataDrivenPropertyValue); + static PropertyValue getDefaultTextField(); + PropertyValue getTextField() const; + void setTextField(PropertyValue); - static DataDrivenPropertyValue> getDefaultTextFont(); - DataDrivenPropertyValue> getTextFont() const; - void setTextFont(DataDrivenPropertyValue>); + static PropertyValue> getDefaultTextFont(); + PropertyValue> getTextFont() const; + void setTextFont(PropertyValue>); - static DataDrivenPropertyValue getDefaultTextSize(); - DataDrivenPropertyValue getTextSize() const; - void setTextSize(DataDrivenPropertyValue); + static PropertyValue getDefaultTextSize(); + PropertyValue getTextSize() const; + void setTextSize(PropertyValue); - static DataDrivenPropertyValue getDefaultTextMaxWidth(); - DataDrivenPropertyValue getTextMaxWidth() const; - void setTextMaxWidth(DataDrivenPropertyValue); + static PropertyValue getDefaultTextMaxWidth(); + PropertyValue getTextMaxWidth() const; + void setTextMaxWidth(PropertyValue); static PropertyValue getDefaultTextLineHeight(); PropertyValue getTextLineHeight() const; void setTextLineHeight(PropertyValue); - static DataDrivenPropertyValue getDefaultTextLetterSpacing(); - DataDrivenPropertyValue getTextLetterSpacing() const; - void setTextLetterSpacing(DataDrivenPropertyValue); + static PropertyValue getDefaultTextLetterSpacing(); + PropertyValue getTextLetterSpacing() const; + void setTextLetterSpacing(PropertyValue); - static DataDrivenPropertyValue getDefaultTextJustify(); - DataDrivenPropertyValue getTextJustify() const; - void setTextJustify(DataDrivenPropertyValue); + static PropertyValue getDefaultTextJustify(); + PropertyValue getTextJustify() const; + void setTextJustify(PropertyValue); - static DataDrivenPropertyValue getDefaultTextAnchor(); - DataDrivenPropertyValue getTextAnchor() const; - void setTextAnchor(DataDrivenPropertyValue); + static PropertyValue getDefaultTextAnchor(); + PropertyValue getTextAnchor() const; + void setTextAnchor(PropertyValue); static PropertyValue getDefaultTextMaxAngle(); PropertyValue getTextMaxAngle() const; void setTextMaxAngle(PropertyValue); - static DataDrivenPropertyValue getDefaultTextRotate(); - DataDrivenPropertyValue getTextRotate() const; - void setTextRotate(DataDrivenPropertyValue); + static PropertyValue getDefaultTextRotate(); + PropertyValue getTextRotate() const; + void setTextRotate(PropertyValue); static PropertyValue getDefaultTextPadding(); PropertyValue getTextPadding() const; @@ -162,13 +161,13 @@ public: PropertyValue getTextKeepUpright() const; void setTextKeepUpright(PropertyValue); - static DataDrivenPropertyValue getDefaultTextTransform(); - DataDrivenPropertyValue getTextTransform() const; - void setTextTransform(DataDrivenPropertyValue); + static PropertyValue getDefaultTextTransform(); + PropertyValue getTextTransform() const; + void setTextTransform(PropertyValue); - static DataDrivenPropertyValue> getDefaultTextOffset(); - DataDrivenPropertyValue> getTextOffset() const; - void setTextOffset(DataDrivenPropertyValue>); + static PropertyValue> getDefaultTextOffset(); + PropertyValue> getTextOffset() const; + void setTextOffset(PropertyValue>); static PropertyValue getDefaultTextAllowOverlap(); PropertyValue getTextAllowOverlap() const; @@ -184,33 +183,33 @@ public: // Paint properties - static DataDrivenPropertyValue getDefaultIconOpacity(); - DataDrivenPropertyValue getIconOpacity() const; - void setIconOpacity(DataDrivenPropertyValue); + static PropertyValue getDefaultIconOpacity(); + PropertyValue getIconOpacity() const; + void setIconOpacity(PropertyValue); void setIconOpacityTransition(const TransitionOptions&); TransitionOptions getIconOpacityTransition() const; - static DataDrivenPropertyValue getDefaultIconColor(); - DataDrivenPropertyValue getIconColor() const; - void setIconColor(DataDrivenPropertyValue); + static PropertyValue getDefaultIconColor(); + PropertyValue getIconColor() const; + void setIconColor(PropertyValue); void setIconColorTransition(const TransitionOptions&); TransitionOptions getIconColorTransition() const; - static DataDrivenPropertyValue getDefaultIconHaloColor(); - DataDrivenPropertyValue getIconHaloColor() const; - void setIconHaloColor(DataDrivenPropertyValue); + static PropertyValue getDefaultIconHaloColor(); + PropertyValue getIconHaloColor() const; + void setIconHaloColor(PropertyValue); void setIconHaloColorTransition(const TransitionOptions&); TransitionOptions getIconHaloColorTransition() const; - static DataDrivenPropertyValue getDefaultIconHaloWidth(); - DataDrivenPropertyValue getIconHaloWidth() const; - void setIconHaloWidth(DataDrivenPropertyValue); + static PropertyValue getDefaultIconHaloWidth(); + PropertyValue getIconHaloWidth() const; + void setIconHaloWidth(PropertyValue); void setIconHaloWidthTransition(const TransitionOptions&); TransitionOptions getIconHaloWidthTransition() const; - static DataDrivenPropertyValue getDefaultIconHaloBlur(); - DataDrivenPropertyValue getIconHaloBlur() const; - void setIconHaloBlur(DataDrivenPropertyValue); + static PropertyValue getDefaultIconHaloBlur(); + PropertyValue getIconHaloBlur() const; + void setIconHaloBlur(PropertyValue); void setIconHaloBlurTransition(const TransitionOptions&); TransitionOptions getIconHaloBlurTransition() const; @@ -226,33 +225,33 @@ public: void setIconTranslateAnchorTransition(const TransitionOptions&); TransitionOptions getIconTranslateAnchorTransition() const; - static DataDrivenPropertyValue getDefaultTextOpacity(); - DataDrivenPropertyValue getTextOpacity() const; - void setTextOpacity(DataDrivenPropertyValue); + static PropertyValue getDefaultTextOpacity(); + PropertyValue getTextOpacity() const; + void setTextOpacity(PropertyValue); void setTextOpacityTransition(const TransitionOptions&); TransitionOptions getTextOpacityTransition() const; - static DataDrivenPropertyValue getDefaultTextColor(); - DataDrivenPropertyValue getTextColor() const; - void setTextColor(DataDrivenPropertyValue); + static PropertyValue getDefaultTextColor(); + PropertyValue getTextColor() const; + void setTextColor(PropertyValue); void setTextColorTransition(const TransitionOptions&); TransitionOptions getTextColorTransition() const; - static DataDrivenPropertyValue getDefaultTextHaloColor(); - DataDrivenPropertyValue getTextHaloColor() const; - void setTextHaloColor(DataDrivenPropertyValue); + static PropertyValue getDefaultTextHaloColor(); + PropertyValue getTextHaloColor() const; + void setTextHaloColor(PropertyValue); void setTextHaloColorTransition(const TransitionOptions&); TransitionOptions getTextHaloColorTransition() const; - static DataDrivenPropertyValue getDefaultTextHaloWidth(); - DataDrivenPropertyValue getTextHaloWidth() const; - void setTextHaloWidth(DataDrivenPropertyValue); + static PropertyValue getDefaultTextHaloWidth(); + PropertyValue getTextHaloWidth() const; + void setTextHaloWidth(PropertyValue); void setTextHaloWidthTransition(const TransitionOptions&); TransitionOptions getTextHaloWidthTransition() const; - static DataDrivenPropertyValue getDefaultTextHaloBlur(); - DataDrivenPropertyValue getTextHaloBlur() const; - void setTextHaloBlur(DataDrivenPropertyValue); + static PropertyValue getDefaultTextHaloBlur(); + PropertyValue getTextHaloBlur() const; + void setTextHaloBlur(PropertyValue); void setTextHaloBlurTransition(const TransitionOptions&); TransitionOptions getTextHaloBlurTransition() const; diff --git a/include/mbgl/style/property_value.hpp b/include/mbgl/style/property_value.hpp index 1b0f3d2ab0..86812e2301 100644 --- a/include/mbgl/style/property_value.hpp +++ b/include/mbgl/style/property_value.hpp @@ -10,44 +10,80 @@ namespace style { template class PropertyValue { private: - using Value = variant>; + using Value = variant< + Undefined, + T, + PropertyExpression>; + Value value; - friend bool operator==(const PropertyValue& lhs, const PropertyValue& rhs) { + friend bool operator==(const PropertyValue& lhs, + const PropertyValue& rhs) { return lhs.value == rhs.value; } - friend bool operator!=(const PropertyValue& lhs, const PropertyValue& rhs) { + friend bool operator!=(const PropertyValue& lhs, + const PropertyValue& rhs) { return !(lhs == rhs); } public: - PropertyValue() - : value() {} + PropertyValue() = default; PropertyValue(T constant) - : value(constant) {} + : value(std::move(constant)) {} PropertyValue(PropertyExpression expression) - : value(expression) { - assert(expression.isFeatureConstant()); + : value(std::move(expression)) {} + + bool isUndefined() const { + return value.template is(); + } + + bool isConstant() const { + return value.template is(); + } + + bool isExpression() const { + return value.template is>(); + } + + bool isDataDriven() const { + return value.match( + [] (const Undefined&) { return false; }, + [] (const T&) { return false; }, + [] (const PropertyExpression& fn) { return !fn.isFeatureConstant(); } + ); + } + + bool isZoomConstant() const { + return value.match( + [] (const Undefined&) { return true; }, + [] (const T&) { return true; }, + [] (const PropertyExpression& fn) { return fn.isZoomConstant(); } + ); } - bool isUndefined() const { return value.which() == 0; } - bool isConstant() const { return value.which() == 1; } - bool isExpression() const { return value.which() == 2; } - bool isDataDriven() const { return false; } + const T& asConstant() const { + return value.template get(); + } - const T & asConstant() const { return value.template get< T >(); } - const PropertyExpression& asExpression() const { return value.template get>(); } + const PropertyExpression& asExpression() const { + return value.template get>(); + } + + template + auto match(Ts&&... ts) const { + return value.match(std::forward(ts)...); + } template auto evaluate(const Evaluator& evaluator, TimePoint = {}) const { return Value::visit(value, evaluator); } - bool hasDataDrivenPropertyDifference(const PropertyValue&) const { - return false; + bool hasDataDrivenPropertyDifference(const PropertyValue& other) const { + return *this != other && (isDataDriven() || other.isDataDriven()); } }; diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js index b435351df5..888b9fca30 100755 --- a/platform/android/scripts/generate-style-code.js +++ b/platform/android/scripts/generate-style-code.js @@ -278,9 +278,6 @@ global.isLightProperty = function (property) { global.propertyValueType = function (property) { switch (property['property-type']) { - case 'data-driven': - case 'cross-faded-data-driven': - return `DataDrivenPropertyValue<${evaluatedType(property)}>`; default: return `PropertyValue<${evaluatedType(property)}>`; } diff --git a/platform/android/src/style/conversion/property_value.hpp b/platform/android/src/style/conversion/property_value.hpp index feed38b673..256647cddf 100644 --- a/platform/android/src/style/conversion/property_value.hpp +++ b/platform/android/src/style/conversion/property_value.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "../../conversion/conversion.hpp" #include "../../conversion/constant.hpp" @@ -51,18 +50,6 @@ struct Converter> { } }; -/** - * Convert core data driven property values to java - */ -template -struct Converter> { - - Result operator()(jni::JNIEnv& env, const mbgl::style::DataDrivenPropertyValue& value) const { - PropertyValueEvaluator evaluator(env); - return value.evaluate(evaluator); - } -}; - /** * Convert core heat map color property value to java */ diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index cc09ce4e11..890c485677 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -35,7 +35,7 @@ - (void)setBackgroundColor:(NSExpression *)backgroundColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundColor, false); self.rawLayer->setBackgroundColor(mbglValue); } @@ -70,7 +70,7 @@ - (void)setBackgroundOpacity:(NSExpression *)backgroundOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundOpacity, false); self.rawLayer->setBackgroundOpacity(mbglValue); } @@ -105,7 +105,7 @@ - (void)setBackgroundPattern:(NSExpression *)backgroundPattern { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundPattern); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(backgroundPattern, false); self.rawLayer->setBackgroundPattern(mbglValue); } diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index b03ab8a7a6..a391d72e7f 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -90,7 +90,7 @@ namespace mbgl { - (void)setCircleBlur:(NSExpression *)circleBlur { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleBlur); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleBlur, true); self.rawLayer->setCircleBlur(mbglValue); } @@ -125,7 +125,7 @@ namespace mbgl { - (void)setCircleColor:(NSExpression *)circleColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleColor, true); self.rawLayer->setCircleColor(mbglValue); } @@ -160,7 +160,7 @@ namespace mbgl { - (void)setCircleOpacity:(NSExpression *)circleOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleOpacity, true); self.rawLayer->setCircleOpacity(mbglValue); } @@ -195,7 +195,7 @@ namespace mbgl { - (void)setCirclePitchAlignment:(NSExpression *)circlePitchAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circlePitchAlignment); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circlePitchAlignment, false); self.rawLayer->setCirclePitchAlignment(mbglValue); } @@ -212,7 +212,7 @@ namespace mbgl { - (void)setCircleRadius:(NSExpression *)circleRadius { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleRadius); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleRadius, true); self.rawLayer->setCircleRadius(mbglValue); } @@ -247,7 +247,7 @@ namespace mbgl { - (void)setCircleScaleAlignment:(NSExpression *)circleScaleAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleScaleAlignment); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleScaleAlignment, false); self.rawLayer->setCirclePitchScale(mbglValue); } @@ -271,7 +271,7 @@ namespace mbgl { - (void)setCircleStrokeColor:(NSExpression *)circleStrokeColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeColor, true); self.rawLayer->setCircleStrokeColor(mbglValue); } @@ -306,7 +306,7 @@ namespace mbgl { - (void)setCircleStrokeOpacity:(NSExpression *)circleStrokeOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeOpacity, true); self.rawLayer->setCircleStrokeOpacity(mbglValue); } @@ -341,7 +341,7 @@ namespace mbgl { - (void)setCircleStrokeWidth:(NSExpression *)circleStrokeWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeWidth); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleStrokeWidth, true); self.rawLayer->setCircleStrokeWidth(mbglValue); } @@ -376,7 +376,7 @@ namespace mbgl { - (void)setCircleTranslation:(NSExpression *)circleTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(circleTranslation); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(circleTranslation, false); self.rawLayer->setCircleTranslate(mbglValue); } @@ -418,7 +418,7 @@ namespace mbgl { - (void)setCircleTranslationAnchor:(NSExpression *)circleTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleTranslationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(circleTranslationAnchor, false); self.rawLayer->setCircleTranslateAnchor(mbglValue); } diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm index 1cb059fae0..1b7896be9f 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm @@ -80,7 +80,7 @@ namespace mbgl { - (void)setFillExtrusionBase:(NSExpression *)fillExtrusionBase { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionBase); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionBase, true); self.rawLayer->setFillExtrusionBase(mbglValue); } @@ -115,7 +115,7 @@ namespace mbgl { - (void)setFillExtrusionColor:(NSExpression *)fillExtrusionColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionColor, true); self.rawLayer->setFillExtrusionColor(mbglValue); } @@ -150,7 +150,7 @@ namespace mbgl { - (void)setFillExtrusionHeight:(NSExpression *)fillExtrusionHeight { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionHeight); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionHeight, true); self.rawLayer->setFillExtrusionHeight(mbglValue); } @@ -185,7 +185,7 @@ namespace mbgl { - (void)setFillExtrusionOpacity:(NSExpression *)fillExtrusionOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionOpacity, false); self.rawLayer->setFillExtrusionOpacity(mbglValue); } @@ -220,7 +220,7 @@ namespace mbgl { - (void)setFillExtrusionPattern:(NSExpression *)fillExtrusionPattern { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionPattern); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionPattern, false); self.rawLayer->setFillExtrusionPattern(mbglValue); } @@ -255,7 +255,7 @@ namespace mbgl { - (void)setFillExtrusionTranslation:(NSExpression *)fillExtrusionTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(fillExtrusionTranslation); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(fillExtrusionTranslation, false); self.rawLayer->setFillExtrusionTranslate(mbglValue); } @@ -297,7 +297,7 @@ namespace mbgl { - (void)setFillExtrusionTranslationAnchor:(NSExpression *)fillExtrusionTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionTranslationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillExtrusionTranslationAnchor, false); self.rawLayer->setFillExtrusionTranslateAnchor(mbglValue); } diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 2fb9849c42..7c36f7989b 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -80,7 +80,7 @@ namespace mbgl { - (void)setFillAntialiased:(NSExpression *)fillAntialiased { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillAntialiased); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillAntialiased, false); self.rawLayer->setFillAntialias(mbglValue); } @@ -104,7 +104,7 @@ namespace mbgl { - (void)setFillColor:(NSExpression *)fillColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillColor, true); self.rawLayer->setFillColor(mbglValue); } @@ -139,7 +139,7 @@ namespace mbgl { - (void)setFillOpacity:(NSExpression *)fillOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillOpacity, true); self.rawLayer->setFillOpacity(mbglValue); } @@ -174,7 +174,7 @@ namespace mbgl { - (void)setFillOutlineColor:(NSExpression *)fillOutlineColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillOutlineColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillOutlineColor, true); self.rawLayer->setFillOutlineColor(mbglValue); } @@ -209,7 +209,7 @@ namespace mbgl { - (void)setFillPattern:(NSExpression *)fillPattern { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillPattern); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillPattern, false); self.rawLayer->setFillPattern(mbglValue); } @@ -244,7 +244,7 @@ namespace mbgl { - (void)setFillTranslation:(NSExpression *)fillTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(fillTranslation); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(fillTranslation, false); self.rawLayer->setFillTranslate(mbglValue); } @@ -286,7 +286,7 @@ namespace mbgl { - (void)setFillTranslationAnchor:(NSExpression *)fillTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillTranslationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(fillTranslationAnchor, false); self.rawLayer->setFillTranslateAnchor(mbglValue); } diff --git a/platform/darwin/src/MGLHeatmapStyleLayer.mm b/platform/darwin/src/MGLHeatmapStyleLayer.mm index 5e6b5df319..c74869d408 100644 --- a/platform/darwin/src/MGLHeatmapStyleLayer.mm +++ b/platform/darwin/src/MGLHeatmapStyleLayer.mm @@ -88,7 +88,7 @@ - (void)setHeatmapIntensity:(NSExpression *)heatmapIntensity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapIntensity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapIntensity, false); self.rawLayer->setHeatmapIntensity(mbglValue); } @@ -123,7 +123,7 @@ - (void)setHeatmapOpacity:(NSExpression *)heatmapOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapOpacity, false); self.rawLayer->setHeatmapOpacity(mbglValue); } @@ -158,7 +158,7 @@ - (void)setHeatmapRadius:(NSExpression *)heatmapRadius { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapRadius); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapRadius, true); self.rawLayer->setHeatmapRadius(mbglValue); } @@ -193,7 +193,7 @@ - (void)setHeatmapWeight:(NSExpression *)heatmapWeight { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapWeight); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(heatmapWeight, true); self.rawLayer->setHeatmapWeight(mbglValue); } diff --git a/platform/darwin/src/MGLHillshadeStyleLayer.mm b/platform/darwin/src/MGLHillshadeStyleLayer.mm index 70fab24e33..16d043f603 100644 --- a/platform/darwin/src/MGLHillshadeStyleLayer.mm +++ b/platform/darwin/src/MGLHillshadeStyleLayer.mm @@ -51,7 +51,7 @@ namespace mbgl { - (void)setHillshadeAccentColor:(NSExpression *)hillshadeAccentColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeAccentColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeAccentColor, false); self.rawLayer->setHillshadeAccentColor(mbglValue); } @@ -86,7 +86,7 @@ namespace mbgl { - (void)setHillshadeExaggeration:(NSExpression *)hillshadeExaggeration { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeExaggeration); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeExaggeration, false); self.rawLayer->setHillshadeExaggeration(mbglValue); } @@ -121,7 +121,7 @@ namespace mbgl { - (void)setHillshadeHighlightColor:(NSExpression *)hillshadeHighlightColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeHighlightColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeHighlightColor, false); self.rawLayer->setHillshadeHighlightColor(mbglValue); } @@ -156,7 +156,7 @@ namespace mbgl { - (void)setHillshadeIlluminationAnchor:(NSExpression *)hillshadeIlluminationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeIlluminationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeIlluminationAnchor, false); self.rawLayer->setHillshadeIlluminationAnchor(mbglValue); } @@ -173,7 +173,7 @@ namespace mbgl { - (void)setHillshadeIlluminationDirection:(NSExpression *)hillshadeIlluminationDirection { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeIlluminationDirection); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeIlluminationDirection, false); self.rawLayer->setHillshadeIlluminationDirection(mbglValue); } @@ -190,7 +190,7 @@ namespace mbgl { - (void)setHillshadeShadowColor:(NSExpression *)hillshadeShadowColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeShadowColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(hillshadeShadowColor, false); self.rawLayer->setHillshadeShadowColor(mbglValue); } diff --git a/platform/darwin/src/MGLLight.mm b/platform/darwin/src/MGLLight.mm index db2893ed44..0234e74d5b 100644 --- a/platform/darwin/src/MGLLight.mm +++ b/platform/darwin/src/MGLLight.mm @@ -18,14 +18,14 @@ namespace mbgl { { MGLLightAnchorMap, "map" }, { MGLLightAnchorViewport, "viewport" }, }); - + } NS_INLINE MGLTransition MGLTransitionFromOptions(const mbgl::style::TransitionOptions& options) { MGLTransition transition; transition.duration = MGLTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); transition.delay = MGLTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); - + return transition; } @@ -60,27 +60,21 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition } else { _position = MGLStyleValueTransformer().toExpression(positionValue); } - _positionTransition = MGLTransitionFromOptions(mbglLight->getPositionTransition()); - auto colorValue = mbglLight->getColor(); if (colorValue.isUndefined()) { _color = MGLStyleValueTransformer().toExpression(mbglLight->getDefaultColor()); } else { _color = MGLStyleValueTransformer().toExpression(colorValue); } - _colorTransition = MGLTransitionFromOptions(mbglLight->getColorTransition()); - auto intensityValue = mbglLight->getIntensity(); if (intensityValue.isUndefined()) { _intensity = MGLStyleValueTransformer().toExpression(mbglLight->getDefaultIntensity()); } else { _intensity = MGLStyleValueTransformer().toExpression(intensityValue); } - _intensityTransition = MGLTransitionFromOptions(mbglLight->getIntensityTransition()); - } return self; @@ -89,25 +83,25 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition - (mbgl::style::Light)mbglLight { mbgl::style::Light mbglLight; - auto anchor = MGLStyleValueTransformer().toPropertyValue>(self.anchor); + auto anchor = MGLStyleValueTransformer().toPropertyValue>(self.anchor, false); mbglLight.setAnchor(anchor); - auto position = MGLStyleValueTransformer().toPropertyValue>(self.position); + auto position = MGLStyleValueTransformer().toPropertyValue>(self.position, false); mbglLight.setPosition(position); - + mbglLight.setPositionTransition(MGLOptionsFromTransition(self.positionTransition)); - auto color = MGLStyleValueTransformer().toPropertyValue>(self.color); + auto color = MGLStyleValueTransformer().toPropertyValue>(self.color, false); mbglLight.setColor(color); - + mbglLight.setColorTransition(MGLOptionsFromTransition(self.colorTransition)); - auto intensity = MGLStyleValueTransformer().toPropertyValue>(self.intensity); + auto intensity = MGLStyleValueTransformer().toPropertyValue>(self.intensity, false); mbglLight.setIntensity(intensity); - + mbglLight.setIntensityTransition(MGLOptionsFromTransition(self.intensityTransition)); - + return mbglLight; } diff --git a/platform/darwin/src/MGLLight.mm.ejs b/platform/darwin/src/MGLLight.mm.ejs index b241269519..24ab1d8138 100644 --- a/platform/darwin/src/MGLLight.mm.ejs +++ b/platform/darwin/src/MGLLight.mm.ejs @@ -26,14 +26,14 @@ namespace mbgl { <% } -%> <% } -%> }); - + } NS_INLINE MGLTransition MGLTransitionFromOptions(const mbgl::style::TransitionOptions& options) { MGLTransition transition; transition.duration = MGLTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); transition.delay = MGLTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); - + return transition; } @@ -76,9 +76,9 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition } else { _<%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toExpression(<%- camelizeWithLeadingLowercase(property.name) -%>Value); } -<% if (property.transition) { -%> +<% if (property.transition) { -%> _<%- camelizeWithLeadingLowercase(property.name) -%>Transition = MGLTransitionFromOptions(mbglLight->get<%- camelize(property.name) -%>Transition()); -<% } -%> +<% } -%> <% } -%> <% } -%> <% } -%> @@ -93,13 +93,13 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition <% if (properties.length) { -%> <% for (const property of properties) { -%> <% if (property.type == "enum") { -%> - auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformerType, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toPropertyValue>>(self.<%- camelizeWithLeadingLowercase(property.name) -%>); + auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformerType, NSValue *, mbgl::style::Light<%- camelize(property.name) -%>Type, MGLLight<%- camelize(property.name) -%>>().toPropertyValue>>(self.<%- camelizeWithLeadingLowercase(property.name) -%>, false); mbglLight.set<%- camelize(property.name) -%>(<%- camelizeWithLeadingLowercase(property.name) -%>); <% } else {-%> - auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(self.<%- camelizeWithLeadingLowercase(property.name) -%>); + auto <%- camelizeWithLeadingLowercase(property.name) -%> = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(self.<%- camelizeWithLeadingLowercase(property.name) -%>, false); mbglLight.set<%- camelize(property.name) -%>(<%- camelizeWithLeadingLowercase(property.name) -%>); - + <% } -%> <% if (property.transition) { -%> mbglLight.set<%- camelize(property.name) -%>Transition(MGLOptionsFromTransition(self.<%- camelizeWithLeadingLowercase(property.name) -%>Transition)); @@ -107,7 +107,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition <% } -%> <% } -%> <% } -%> - + return mbglLight; } diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index e65a474829..3bad2a8b98 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -92,7 +92,7 @@ namespace mbgl { - (void)setLineCap:(NSExpression *)lineCap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineCap); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineCap, false); self.rawLayer->setLineCap(mbglValue); } @@ -109,7 +109,7 @@ namespace mbgl { - (void)setLineJoin:(NSExpression *)lineJoin { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineJoin); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineJoin, true); self.rawLayer->setLineJoin(mbglValue); } @@ -126,7 +126,7 @@ namespace mbgl { - (void)setLineMiterLimit:(NSExpression *)lineMiterLimit { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineMiterLimit); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineMiterLimit, false); self.rawLayer->setLineMiterLimit(mbglValue); } @@ -143,7 +143,7 @@ namespace mbgl { - (void)setLineRoundLimit:(NSExpression *)lineRoundLimit { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineRoundLimit); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineRoundLimit, false); self.rawLayer->setLineRoundLimit(mbglValue); } @@ -162,7 +162,7 @@ namespace mbgl { - (void)setLineBlur:(NSExpression *)lineBlur { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineBlur); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineBlur, true); self.rawLayer->setLineBlur(mbglValue); } @@ -197,7 +197,7 @@ namespace mbgl { - (void)setLineColor:(NSExpression *)lineColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineColor, true); self.rawLayer->setLineColor(mbglValue); } @@ -232,7 +232,7 @@ namespace mbgl { - (void)setLineDashPattern:(NSExpression *)lineDashPattern { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSArray *, float>().toPropertyValue>>(lineDashPattern); + auto mbglValue = MGLStyleValueTransformer, NSArray *, float>().toPropertyValue>>(lineDashPattern, false); self.rawLayer->setLineDasharray(mbglValue); } @@ -274,7 +274,7 @@ namespace mbgl { - (void)setLineGapWidth:(NSExpression *)lineGapWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineGapWidth); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineGapWidth, true); self.rawLayer->setLineGapWidth(mbglValue); } @@ -309,7 +309,7 @@ namespace mbgl { - (void)setLineOffset:(NSExpression *)lineOffset { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineOffset); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineOffset, true); self.rawLayer->setLineOffset(mbglValue); } @@ -344,7 +344,7 @@ namespace mbgl { - (void)setLineOpacity:(NSExpression *)lineOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineOpacity, true); self.rawLayer->setLineOpacity(mbglValue); } @@ -379,7 +379,7 @@ namespace mbgl { - (void)setLinePattern:(NSExpression *)linePattern { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(linePattern); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(linePattern, false); self.rawLayer->setLinePattern(mbglValue); } @@ -414,7 +414,7 @@ namespace mbgl { - (void)setLineTranslation:(NSExpression *)lineTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(lineTranslation); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(lineTranslation, false); self.rawLayer->setLineTranslate(mbglValue); } @@ -456,7 +456,7 @@ namespace mbgl { - (void)setLineTranslationAnchor:(NSExpression *)lineTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineTranslationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineTranslationAnchor, false); self.rawLayer->setLineTranslateAnchor(mbglValue); } @@ -480,7 +480,7 @@ namespace mbgl { - (void)setLineWidth:(NSExpression *)lineWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineWidth); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(lineWidth, true); self.rawLayer->setLineWidth(mbglValue); } diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index 96ed5ab513..c87355b04d 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -51,7 +51,7 @@ namespace mbgl { - (void)setMaximumRasterBrightness:(NSExpression *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumRasterBrightness); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumRasterBrightness, false); self.rawLayer->setRasterBrightnessMax(mbglValue); } @@ -93,7 +93,7 @@ namespace mbgl { - (void)setMinimumRasterBrightness:(NSExpression *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(minimumRasterBrightness); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(minimumRasterBrightness, false); self.rawLayer->setRasterBrightnessMin(mbglValue); } @@ -135,7 +135,7 @@ namespace mbgl { - (void)setRasterContrast:(NSExpression *)rasterContrast { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterContrast); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterContrast, false); self.rawLayer->setRasterContrast(mbglValue); } @@ -170,7 +170,7 @@ namespace mbgl { - (void)setRasterFadeDuration:(NSExpression *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterFadeDuration); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterFadeDuration, false); self.rawLayer->setRasterFadeDuration(mbglValue); } @@ -187,7 +187,7 @@ namespace mbgl { - (void)setRasterHueRotation:(NSExpression *)rasterHueRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterHueRotation); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterHueRotation, false); self.rawLayer->setRasterHueRotate(mbglValue); } @@ -229,7 +229,7 @@ namespace mbgl { - (void)setRasterOpacity:(NSExpression *)rasterOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterOpacity, false); self.rawLayer->setRasterOpacity(mbglValue); } @@ -264,7 +264,7 @@ namespace mbgl { - (void)setRasterResamplingMode:(NSExpression *)rasterResamplingMode { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterResamplingMode); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterResamplingMode, false); self.rawLayer->setRasterResampling(mbglValue); } @@ -288,7 +288,7 @@ namespace mbgl { - (void)setRasterSaturation:(NSExpression *)rasterSaturation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterSaturation); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(rasterSaturation, false); self.rawLayer->setRasterSaturation(mbglValue); } diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index b37fbc04bf..0707e573c4 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -125,16 +125,16 @@ namespace mbgl { if (<%- objCName(property) %> && <%- objCName(property) %>.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)<%- objCName(property) %>.constantValue).UTF8String; if (mbgl::style::conversion::hasTokens(string)) { - self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbgl::style::DataDrivenPropertyValue( + self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbgl::style::PropertyValue( mbgl::style::conversion::convertTokenStringToExpression(string))); return; } } <% } -%> <% if (isDataDriven(property)) { -%> - auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>, true); <% } else { -%> - auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>, false); <% } -%> self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); } @@ -173,10 +173,10 @@ namespace mbgl { <% break case 'data-driven': case 'cross-faded-data-driven': -%> - auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>, true); <% break default: -%> - auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue>>(<%- objCName(property) %>, false); <% } -%> self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); } diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index d6e2edf3eb..75e422fb45 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -10,14 +10,10 @@ #import "MGLConversion.h" #include #include -#include #include #import #import - -#include - #include #if TARGET_OS_IPHONE @@ -39,20 +35,13 @@ id MGLJSONObjectFromMBGLExpression(const mbgl::style::expression::Expression &mb template class MGLStyleValueTransformer { public: - + /// Convert an mbgl property value into an mgl style value NSExpression *toExpression(const mbgl::style::PropertyValue &mbglValue) { PropertyExpressionEvaluator evaluator; return mbglValue.evaluate(evaluator); } - - /// Convert an mbgl data driven property value into an mgl style value - template - NSExpression *toExpression(const mbgl::style::DataDrivenPropertyValue &mbglValue) { - PropertyExpressionEvaluator evaluator; - return mbglValue.evaluate(evaluator); - } - + // Convert an mbgl heatmap color property value into an mgl style value NSExpression *toExpression(const mbgl::style::ColorRampPropertyValue &mbglValue) { if (mbglValue.isUndefined()) { @@ -66,11 +55,11 @@ public: */ template typename std::enable_if_t::value, - MBGLValue> toPropertyValue(NSExpression *expression) { + MBGLValue> toPropertyValue(NSExpression *expression, bool allowDataExpressions) { if (!expression) { return {}; } - + if (expression.expressionType == NSConstantValueExpressionType) { MBGLType mbglValue; getMBGLValue(expression.constantValue, mbglValue); @@ -81,21 +70,21 @@ public: getMBGLValue(expression.collection, mbglValue); return mbglValue; } - + NSArray *jsonExpression = expression.mgl_jsonExpressionObject; - + mbgl::style::conversion::Error valueError; auto value = mbgl::style::conversion::convert( - mbgl::style::conversion::makeConvertible(jsonExpression), valueError, false); + mbgl::style::conversion::makeConvertible(jsonExpression), valueError, allowDataExpressions, false); if (!value) { [NSException raise:NSInvalidArgumentException format:@"Invalid property value: %@", @(valueError.message.c_str())]; return {}; } - + return *value; } - + /** Converts an NSExpression to an mbgl property value. */ @@ -105,9 +94,9 @@ public: if (!expression) { return {}; } - + NSArray *jsonExpression = expression.mgl_jsonExpressionObject; - + mbgl::style::conversion::Error valueError; auto value = mbgl::style::conversion::convert( mbgl::style::conversion::makeConvertible(jsonExpression), valueError); @@ -116,12 +105,12 @@ public: format:@"Invalid property value: %@", @(valueError.message.c_str())]; return {}; } - + return *value; } private: // Private utilities for converting from mgl to mbgl values - + /** As hack to allow converting enum => string values, we accept a second, dummy parameter in the toRawStyleSpecValue() methods for converting 'atomic' (non-style-function) values. @@ -143,7 +132,7 @@ private: // Private utilities for converting from mgl to mbgl values // noop pass-through plain NSObject-based items return rawMGLValue; } - + template ::value>::type, typename MGLEnum = ObjCEnum, @@ -153,7 +142,7 @@ private: // Private utilities for converting from mgl to mbgl values [rawValue getValue:&mglEnum]; return @(mbgl::Enum::toString(mglEnum)); } - + NSObject* toRawStyleSpecValue(MGLColor *color, MBGLType &mbglValue) { return @(color.mgl_color.stringify().c_str()); } @@ -216,7 +205,7 @@ private: // Private utilities for converting from mgl to mbgl values mbglValue.push_back(mbglElement); } } - + void getMBGLValue(NSValue *rawValue, mbgl::style::Position &mbglValue) { auto spherical = rawValue.mgl_lightPositionArrayValue; mbgl::style::Position position(spherical); @@ -284,7 +273,7 @@ private: // Private utilities for converting from mbgl to mgl values } return array; } - + static NSValue *toMGLRawStyleValue(const mbgl::style::Position &mbglStopValue) { std::array spherical = mbglStopValue.getSpherical(); MGLSphericalPosition position = MGLSphericalPositionMake(spherical[0], spherical[1], spherical[2]); @@ -322,7 +311,7 @@ private: // Private utilities for converting from mbgl to mgl values } return [NSExpression expressionForConstantValue:constantValue]; } - + template ::value>::type, typename MGLEnum = ObjCEnum, diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 791bb5f894..ad023a1a03 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -158,7 +158,7 @@ namespace mbgl { - (void)setIconAllowsOverlap:(NSExpression *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconAllowsOverlap); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconAllowsOverlap, false); self.rawLayer->setIconAllowOverlap(mbglValue); } @@ -182,7 +182,7 @@ namespace mbgl { - (void)setIconAnchor:(NSExpression *)iconAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconAnchor, true); self.rawLayer->setIconAnchor(mbglValue); } @@ -199,7 +199,7 @@ namespace mbgl { - (void)setIconIgnoresPlacement:(NSExpression *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconIgnoresPlacement); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconIgnoresPlacement, false); self.rawLayer->setIconIgnorePlacement(mbglValue); } @@ -226,12 +226,12 @@ namespace mbgl { if (iconImageName && iconImageName.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)iconImageName.constantValue).UTF8String; if (mbgl::style::conversion::hasTokens(string)) { - self.rawLayer->setIconImage(mbgl::style::DataDrivenPropertyValue( + self.rawLayer->setIconImage(mbgl::style::PropertyValue( mbgl::style::conversion::convertTokenStringToExpression(string))); return; } } - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconImageName); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconImageName, true); self.rawLayer->setIconImage(mbglValue); } @@ -255,7 +255,7 @@ namespace mbgl { - (void)setIconOffset:(NSExpression *)iconOffset { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconOffset); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconOffset, true); self.rawLayer->setIconOffset(mbglValue); } @@ -272,7 +272,7 @@ namespace mbgl { - (void)setIconOptional:(NSExpression *)iconOptional { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconOptional); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconOptional, false); self.rawLayer->setIconOptional(mbglValue); } @@ -289,7 +289,7 @@ namespace mbgl { - (void)setIconPadding:(NSExpression *)iconPadding { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconPadding); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconPadding, false); self.rawLayer->setIconPadding(mbglValue); } @@ -306,7 +306,7 @@ namespace mbgl { - (void)setIconPitchAlignment:(NSExpression *)iconPitchAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconPitchAlignment); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconPitchAlignment, false); self.rawLayer->setIconPitchAlignment(mbglValue); } @@ -323,7 +323,7 @@ namespace mbgl { - (void)setIconRotation:(NSExpression *)iconRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconRotation); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconRotation, true); self.rawLayer->setIconRotate(mbglValue); } @@ -347,7 +347,7 @@ namespace mbgl { - (void)setIconRotationAlignment:(NSExpression *)iconRotationAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconRotationAlignment); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconRotationAlignment, false); self.rawLayer->setIconRotationAlignment(mbglValue); } @@ -364,7 +364,7 @@ namespace mbgl { - (void)setIconScale:(NSExpression *)iconScale { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconScale); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconScale, true); self.rawLayer->setIconSize(mbglValue); } @@ -388,7 +388,7 @@ namespace mbgl { - (void)setIconTextFit:(NSExpression *)iconTextFit { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconTextFit); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconTextFit, false); self.rawLayer->setIconTextFit(mbglValue); } @@ -405,7 +405,7 @@ namespace mbgl { - (void)setIconTextFitPadding:(NSExpression *)iconTextFitPadding { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconTextFitPadding); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconTextFitPadding, false); self.rawLayer->setIconTextFitPadding(mbglValue); } @@ -422,7 +422,7 @@ namespace mbgl { - (void)setKeepsIconUpright:(NSExpression *)keepsIconUpright { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(keepsIconUpright); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(keepsIconUpright, false); self.rawLayer->setIconKeepUpright(mbglValue); } @@ -446,7 +446,7 @@ namespace mbgl { - (void)setKeepsTextUpright:(NSExpression *)keepsTextUpright { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(keepsTextUpright); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(keepsTextUpright, false); self.rawLayer->setTextKeepUpright(mbglValue); } @@ -470,7 +470,7 @@ namespace mbgl { - (void)setMaximumTextAngle:(NSExpression *)maximumTextAngle { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumTextAngle); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumTextAngle, false); self.rawLayer->setTextMaxAngle(mbglValue); } @@ -494,7 +494,7 @@ namespace mbgl { - (void)setMaximumTextWidth:(NSExpression *)maximumTextWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumTextWidth); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(maximumTextWidth, true); self.rawLayer->setTextMaxWidth(mbglValue); } @@ -518,7 +518,7 @@ namespace mbgl { - (void)setSymbolAvoidsEdges:(NSExpression *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolAvoidsEdges); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolAvoidsEdges, false); self.rawLayer->setSymbolAvoidEdges(mbglValue); } @@ -542,7 +542,7 @@ namespace mbgl { - (void)setSymbolPlacement:(NSExpression *)symbolPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolPlacement); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolPlacement, false); self.rawLayer->setSymbolPlacement(mbglValue); } @@ -559,7 +559,7 @@ namespace mbgl { - (void)setSymbolSpacing:(NSExpression *)symbolSpacing { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolSpacing); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(symbolSpacing, false); self.rawLayer->setSymbolSpacing(mbglValue); } @@ -579,12 +579,12 @@ namespace mbgl { if (text && text.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)text.constantValue).UTF8String; if (mbgl::style::conversion::hasTokens(string)) { - self.rawLayer->setTextField(mbgl::style::DataDrivenPropertyValue( + self.rawLayer->setTextField(mbgl::style::PropertyValue( mbgl::style::conversion::convertTokenStringToExpression(string))); return; } } - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(text); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(text, true); self.rawLayer->setTextField(mbglValue); } @@ -608,7 +608,7 @@ namespace mbgl { - (void)setTextAllowsOverlap:(NSExpression *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textAllowsOverlap); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textAllowsOverlap, false); self.rawLayer->setTextAllowOverlap(mbglValue); } @@ -632,7 +632,7 @@ namespace mbgl { - (void)setTextAnchor:(NSExpression *)textAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textAnchor, true); self.rawLayer->setTextAnchor(mbglValue); } @@ -649,7 +649,7 @@ namespace mbgl { - (void)setTextFontNames:(NSExpression *)textFontNames { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue>>(textFontNames); + auto mbglValue = MGLStyleValueTransformer, NSArray *, std::string>().toPropertyValue>>(textFontNames, true); self.rawLayer->setTextFont(mbglValue); } @@ -673,7 +673,7 @@ namespace mbgl { - (void)setTextFontSize:(NSExpression *)textFontSize { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textFontSize); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textFontSize, true); self.rawLayer->setTextSize(mbglValue); } @@ -697,7 +697,7 @@ namespace mbgl { - (void)setTextIgnoresPlacement:(NSExpression *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textIgnoresPlacement); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textIgnoresPlacement, false); self.rawLayer->setTextIgnorePlacement(mbglValue); } @@ -721,7 +721,7 @@ namespace mbgl { - (void)setTextJustification:(NSExpression *)textJustification { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textJustification); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textJustification, true); self.rawLayer->setTextJustify(mbglValue); } @@ -745,7 +745,7 @@ namespace mbgl { - (void)setTextLetterSpacing:(NSExpression *)textLetterSpacing { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textLetterSpacing); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textLetterSpacing, true); self.rawLayer->setTextLetterSpacing(mbglValue); } @@ -762,7 +762,7 @@ namespace mbgl { - (void)setTextLineHeight:(NSExpression *)textLineHeight { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textLineHeight); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textLineHeight, false); self.rawLayer->setTextLineHeight(mbglValue); } @@ -779,7 +779,7 @@ namespace mbgl { - (void)setTextOffset:(NSExpression *)textOffset { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(textOffset); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(textOffset, true); self.rawLayer->setTextOffset(mbglValue); } @@ -796,7 +796,7 @@ namespace mbgl { - (void)setTextOptional:(NSExpression *)textOptional { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textOptional); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textOptional, false); self.rawLayer->setTextOptional(mbglValue); } @@ -813,7 +813,7 @@ namespace mbgl { - (void)setTextPadding:(NSExpression *)textPadding { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textPadding); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textPadding, false); self.rawLayer->setTextPadding(mbglValue); } @@ -830,7 +830,7 @@ namespace mbgl { - (void)setTextPitchAlignment:(NSExpression *)textPitchAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textPitchAlignment); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textPitchAlignment, false); self.rawLayer->setTextPitchAlignment(mbglValue); } @@ -847,7 +847,7 @@ namespace mbgl { - (void)setTextRotation:(NSExpression *)textRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRotation); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRotation, true); self.rawLayer->setTextRotate(mbglValue); } @@ -871,7 +871,7 @@ namespace mbgl { - (void)setTextRotationAlignment:(NSExpression *)textRotationAlignment { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRotationAlignment); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textRotationAlignment, false); self.rawLayer->setTextRotationAlignment(mbglValue); } @@ -888,7 +888,7 @@ namespace mbgl { - (void)setTextTransform:(NSExpression *)textTransform { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textTransform); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textTransform, true); self.rawLayer->setTextTransform(mbglValue); } @@ -907,7 +907,7 @@ namespace mbgl { - (void)setIconColor:(NSExpression *)iconColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconColor, true); self.rawLayer->setIconColor(mbglValue); } @@ -942,7 +942,7 @@ namespace mbgl { - (void)setIconHaloBlur:(NSExpression *)iconHaloBlur { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloBlur); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloBlur, true); self.rawLayer->setIconHaloBlur(mbglValue); } @@ -977,7 +977,7 @@ namespace mbgl { - (void)setIconHaloColor:(NSExpression *)iconHaloColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloColor, true); self.rawLayer->setIconHaloColor(mbglValue); } @@ -1012,7 +1012,7 @@ namespace mbgl { - (void)setIconHaloWidth:(NSExpression *)iconHaloWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloWidth); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconHaloWidth, true); self.rawLayer->setIconHaloWidth(mbglValue); } @@ -1047,7 +1047,7 @@ namespace mbgl { - (void)setIconOpacity:(NSExpression *)iconOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconOpacity, true); self.rawLayer->setIconOpacity(mbglValue); } @@ -1082,7 +1082,7 @@ namespace mbgl { - (void)setIconTranslation:(NSExpression *)iconTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconTranslation); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(iconTranslation, false); self.rawLayer->setIconTranslate(mbglValue); } @@ -1124,7 +1124,7 @@ namespace mbgl { - (void)setIconTranslationAnchor:(NSExpression *)iconTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconTranslationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(iconTranslationAnchor, false); self.rawLayer->setIconTranslateAnchor(mbglValue); } @@ -1148,7 +1148,7 @@ namespace mbgl { - (void)setTextColor:(NSExpression *)textColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textColor, true); self.rawLayer->setTextColor(mbglValue); } @@ -1183,7 +1183,7 @@ namespace mbgl { - (void)setTextHaloBlur:(NSExpression *)textHaloBlur { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloBlur); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloBlur, true); self.rawLayer->setTextHaloBlur(mbglValue); } @@ -1218,7 +1218,7 @@ namespace mbgl { - (void)setTextHaloColor:(NSExpression *)textHaloColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloColor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloColor, true); self.rawLayer->setTextHaloColor(mbglValue); } @@ -1253,7 +1253,7 @@ namespace mbgl { - (void)setTextHaloWidth:(NSExpression *)textHaloWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloWidth); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textHaloWidth, true); self.rawLayer->setTextHaloWidth(mbglValue); } @@ -1288,7 +1288,7 @@ namespace mbgl { - (void)setTextOpacity:(NSExpression *)textOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textOpacity); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textOpacity, true); self.rawLayer->setTextOpacity(mbglValue); } @@ -1323,7 +1323,7 @@ namespace mbgl { - (void)setTextTranslation:(NSExpression *)textTranslation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(textTranslation); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue>>(textTranslation, false); self.rawLayer->setTextTranslate(mbglValue); } @@ -1365,7 +1365,7 @@ namespace mbgl { - (void)setTextTranslationAnchor:(NSExpression *)textTranslationAnchor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textTranslationAnchor); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue>(textTranslationAnchor, false); self.rawLayer->setTextTranslateAnchor(mbglValue); } diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.mm b/platform/darwin/test/MGLCircleStyleLayerTests.mm index 7bfccd65ef..853ec67968 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.mm +++ b/platform/darwin/test/MGLCircleStyleLayerTests.mm @@ -57,7 +57,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.circleBlur = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getCircleBlur(), propertyValue, @"Setting circleBlur to a constant value expression should update circle-blur."); XCTAssertEqualObjects(layer.circleBlur, constantExpression, @@ -104,7 +104,7 @@ 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}]; @@ -135,7 +135,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.circleColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getCircleColor(), propertyValue, @"Setting circleColor to a constant value expression should update circle-color."); XCTAssertEqualObjects(layer.circleColor, constantExpression, @@ -182,7 +182,7 @@ 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}]; @@ -213,7 +213,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.circleOpacity = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getCircleOpacity(), propertyValue, @"Setting circleOpacity to a constant value expression should update circle-opacity."); XCTAssertEqualObjects(layer.circleOpacity, constantExpression, @@ -260,7 +260,7 @@ 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}]; @@ -335,7 +335,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.circleRadius = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getCircleRadius(), propertyValue, @"Setting circleRadius to a constant value expression should update circle-radius."); XCTAssertEqualObjects(layer.circleRadius, constantExpression, @@ -382,7 +382,7 @@ 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}]; @@ -457,7 +457,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.circleStrokeColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getCircleStrokeColor(), propertyValue, @"Setting circleStrokeColor to a constant value expression should update circle-stroke-color."); XCTAssertEqualObjects(layer.circleStrokeColor, constantExpression, @@ -504,7 +504,7 @@ 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}]; @@ -535,7 +535,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.circleStrokeOpacity = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getCircleStrokeOpacity(), propertyValue, @"Setting circleStrokeOpacity to a constant value expression should update circle-stroke-opacity."); XCTAssertEqualObjects(layer.circleStrokeOpacity, constantExpression, @@ -582,7 +582,7 @@ 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}]; @@ -613,7 +613,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.circleStrokeWidth = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getCircleStrokeWidth(), propertyValue, @"Setting circleStrokeWidth to a constant value expression should update circle-stroke-width."); XCTAssertEqualObjects(layer.circleStrokeWidth, constantExpression, @@ -660,7 +660,7 @@ 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}]; diff --git a/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm b/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm index 6427d672e7..54808f6b3c 100644 --- a/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm +++ b/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm @@ -57,7 +57,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.fillExtrusionBase = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getFillExtrusionBase(), propertyValue, @"Setting fillExtrusionBase to a constant value expression should update fill-extrusion-base."); XCTAssertEqualObjects(layer.fillExtrusionBase, constantExpression, @@ -104,7 +104,7 @@ 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}]; @@ -135,7 +135,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.fillExtrusionColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getFillExtrusionColor(), propertyValue, @"Setting fillExtrusionColor to a constant value expression should update fill-extrusion-color."); XCTAssertEqualObjects(layer.fillExtrusionColor, constantExpression, @@ -182,7 +182,7 @@ 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}]; @@ -213,7 +213,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.fillExtrusionHeight = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getFillExtrusionHeight(), propertyValue, @"Setting fillExtrusionHeight to a constant value expression should update fill-extrusion-height."); XCTAssertEqualObjects(layer.fillExtrusionHeight, constantExpression, @@ -260,7 +260,7 @@ 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}]; diff --git a/platform/darwin/test/MGLFillStyleLayerTests.mm b/platform/darwin/test/MGLFillStyleLayerTests.mm index 921b59416b..41ee820918 100644 --- a/platform/darwin/test/MGLFillStyleLayerTests.mm +++ b/platform/darwin/test/MGLFillStyleLayerTests.mm @@ -101,7 +101,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.fillColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getFillColor(), propertyValue, @"Setting fillColor to a constant value expression should update fill-color."); XCTAssertEqualObjects(layer.fillColor, constantExpression, @@ -148,7 +148,7 @@ 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}]; @@ -179,7 +179,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.fillOpacity = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getFillOpacity(), propertyValue, @"Setting fillOpacity to a constant value expression should update fill-opacity."); XCTAssertEqualObjects(layer.fillOpacity, constantExpression, @@ -226,7 +226,7 @@ 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}]; @@ -257,7 +257,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.fillOutlineColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getFillOutlineColor(), propertyValue, @"Setting fillOutlineColor to a constant value expression should update fill-outline-color."); XCTAssertEqualObjects(layer.fillOutlineColor, constantExpression, @@ -304,7 +304,7 @@ 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}]; diff --git a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm index a51a324cd9..76a2b0c87e 100644 --- a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm +++ b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm @@ -163,7 +163,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.heatmapRadius = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getHeatmapRadius(), propertyValue, @"Setting heatmapRadius to a constant value expression should update heatmap-radius."); XCTAssertEqualObjects(layer.heatmapRadius, constantExpression, @@ -210,7 +210,7 @@ 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}]; @@ -241,7 +241,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.heatmapWeight = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getHeatmapWeight(), propertyValue, @"Setting heatmapWeight to a constant value expression should update heatmap-weight."); XCTAssertEqualObjects(layer.heatmapWeight, constantExpression, @@ -288,7 +288,7 @@ 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}]; diff --git a/platform/darwin/test/MGLLineStyleLayerTests.mm b/platform/darwin/test/MGLLineStyleLayerTests.mm index 8ad354ef58..4c0f91ba3b 100644 --- a/platform/darwin/test/MGLLineStyleLayerTests.mm +++ b/platform/darwin/test/MGLLineStyleLayerTests.mm @@ -101,7 +101,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'miter'"]; layer.lineJoin = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { mbgl::style::LineJoinType::Miter }; + mbgl::style::PropertyValue propertyValue = { mbgl::style::LineJoinType::Miter }; XCTAssertEqual(rawLayer->getLineJoin(), propertyValue, @"Setting lineJoin to a constant value expression should update line-join."); XCTAssertEqualObjects(layer.lineJoin, constantExpression, @@ -227,7 +227,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.lineBlur = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getLineBlur(), propertyValue, @"Setting lineBlur to a constant value expression should update line-blur."); XCTAssertEqualObjects(layer.lineBlur, constantExpression, @@ -274,7 +274,7 @@ 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}]; @@ -305,7 +305,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.lineColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getLineColor(), propertyValue, @"Setting lineColor to a constant value expression should update line-color."); XCTAssertEqualObjects(layer.lineColor, constantExpression, @@ -352,7 +352,7 @@ 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}]; @@ -427,7 +427,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.lineGapWidth = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getLineGapWidth(), propertyValue, @"Setting lineGapWidth to a constant value expression should update line-gap-width."); XCTAssertEqualObjects(layer.lineGapWidth, constantExpression, @@ -474,7 +474,7 @@ 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}]; @@ -505,7 +505,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.lineOffset = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getLineOffset(), propertyValue, @"Setting lineOffset to a constant value expression should update line-offset."); XCTAssertEqualObjects(layer.lineOffset, constantExpression, @@ -552,7 +552,7 @@ 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}]; @@ -583,7 +583,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.lineOpacity = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getLineOpacity(), propertyValue, @"Setting lineOpacity to a constant value expression should update line-opacity."); XCTAssertEqualObjects(layer.lineOpacity, constantExpression, @@ -630,7 +630,7 @@ 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}]; @@ -808,7 +808,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.lineWidth = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getLineWidth(), propertyValue, @"Setting lineWidth to a constant value expression should update line-width."); XCTAssertEqualObjects(layer.lineWidth, constantExpression, @@ -855,7 +855,7 @@ 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}]; diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs index 02c4a04e6f..89b6cbe7e4 100644 --- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs +++ b/platform/darwin/test/MGLStyleLayerTests.mm.ejs @@ -70,11 +70,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:<%- objCTestValue(property, type, true, 3) %>]; layer.<%- objCName(property) %> = constantExpression; -<% if (isDataDriven(property)) { -%> - mbgl::style::DataDrivenPropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> }; -<% } else { -%> mbgl::style::PropertyValue<<%- mbglType(property) %>> propertyValue = { <%- mbglTestValue(property, type) %> }; -<% } -%> XCTAssertEqual(rawLayer->get<%- camelize(originalPropertyName(property)) %>(), propertyValue, @"Setting <%- objCName(property) %> to a constant value expression should update <%- originalPropertyName(property) %>."); XCTAssertEqualObjects(layer.<%- objCName(property) %>, constantExpression, @@ -122,7 +118,7 @@ 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}]; diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm index 9d772b6bd9..5c108a1ac3 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm @@ -101,7 +101,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"]; layer.iconAnchor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { mbgl::style::SymbolAnchorType::BottomRight }; + mbgl::style::PropertyValue propertyValue = { mbgl::style::SymbolAnchorType::BottomRight }; XCTAssertEqual(rawLayer->getIconAnchor(), propertyValue, @"Setting iconAnchor to a constant value expression should update icon-anchor."); XCTAssertEqualObjects(layer.iconAnchor, constantExpression, @@ -183,7 +183,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'Icon Image'"]; layer.iconImageName = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { "Icon Image" }; + mbgl::style::PropertyValue propertyValue = { "Icon Image" }; XCTAssertEqual(rawLayer->getIconImage(), propertyValue, @"Setting iconImageName to a constant value expression should update icon-image."); XCTAssertEqualObjects(layer.iconImageName, constantExpression, @@ -242,7 +242,7 @@ #endif ]; layer.iconOffset = constantExpression; - mbgl::style::DataDrivenPropertyValue> propertyValue = { { 1, 1 } }; + mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; XCTAssertEqual(rawLayer->getIconOffset(), propertyValue, @"Setting iconOffset to a constant value expression should update icon-offset."); XCTAssertEqualObjects(layer.iconOffset, constantExpression, @@ -289,7 +289,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 }))) ); } - + XCTAssertEqual(rawLayer->getIconOffset(), propertyValue, @"Setting iconOffset to a camera-data expression should update icon-offset."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -443,7 +443,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.iconRotation = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getIconRotate(), propertyValue, @"Setting iconRotation to a constant value expression should update icon-rotate."); XCTAssertEqualObjects(layer.iconRotation, constantExpression, @@ -490,7 +490,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getIconRotate(), propertyValue, @"Setting iconRotation to a camera-data expression should update icon-rotate."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -556,7 +556,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.iconScale = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getIconSize(), propertyValue, @"Setting iconScale to a constant value expression should update icon-size."); XCTAssertEqualObjects(layer.iconScale, constantExpression, @@ -603,7 +603,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getIconSize(), propertyValue, @"Setting iconScale to a camera-data expression should update icon-size."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -851,7 +851,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.maximumTextWidth = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue, @"Setting maximumTextWidth to a constant value expression should update text-max-width."); XCTAssertEqualObjects(layer.maximumTextWidth, constantExpression, @@ -898,7 +898,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextMaxWidth(), propertyValue, @"Setting maximumTextWidth to a camera-data expression should update text-max-width."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -1052,7 +1052,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'Text Field'"]; layer.text = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { "Text Field" }; + mbgl::style::PropertyValue propertyValue = { "Text Field" }; XCTAssertEqual(rawLayer->getTextField(), propertyValue, @"Setting text to a constant value expression should update text-field."); XCTAssertEqualObjects(layer.text, constantExpression, @@ -1149,7 +1149,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'bottom-right'"]; layer.textAnchor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { mbgl::style::SymbolAnchorType::BottomRight }; + mbgl::style::PropertyValue propertyValue = { mbgl::style::SymbolAnchorType::BottomRight }; XCTAssertEqual(rawLayer->getTextAnchor(), propertyValue, @"Setting textAnchor to a constant value expression should update text-anchor."); XCTAssertEqualObjects(layer.textAnchor, constantExpression, @@ -1187,7 +1187,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"{'Text Font', 'Tnof Txet'}"]; layer.textFontNames = constantExpression; - mbgl::style::DataDrivenPropertyValue> propertyValue = { { "Text Font", "Tnof Txet" } }; + mbgl::style::PropertyValue> propertyValue = { { "Text Font", "Tnof Txet" } }; XCTAssertEqual(rawLayer->getTextFont(), propertyValue, @"Setting textFontNames to a constant value expression should update text-font."); XCTAssertEqualObjects(layer.textFontNames, constantExpression, @@ -1225,7 +1225,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.textFontSize = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextSize(), propertyValue, @"Setting textFontSize to a constant value expression should update text-size."); XCTAssertEqualObjects(layer.textFontSize, constantExpression, @@ -1272,7 +1272,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextSize(), propertyValue, @"Setting textFontSize to a camera-data expression should update text-size."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -1338,7 +1338,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'right'"]; layer.textJustification = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { mbgl::style::TextJustifyType::Right }; + mbgl::style::PropertyValue propertyValue = { mbgl::style::TextJustifyType::Right }; XCTAssertEqual(rawLayer->getTextJustify(), propertyValue, @"Setting textJustification to a constant value expression should update text-justify."); XCTAssertEqualObjects(layer.textJustification, constantExpression, @@ -1376,7 +1376,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.textLetterSpacing = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue, @"Setting textLetterSpacing to a constant value expression should update text-letter-spacing."); XCTAssertEqualObjects(layer.textLetterSpacing, constantExpression, @@ -1423,7 +1423,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextLetterSpacing(), propertyValue, @"Setting textLetterSpacing to a camera-data expression should update text-letter-spacing."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -1495,7 +1495,7 @@ #endif ]; layer.textOffset = constantExpression; - mbgl::style::DataDrivenPropertyValue> propertyValue = { { 1, 1 } }; + mbgl::style::PropertyValue> propertyValue = { { 1, 1 } }; XCTAssertEqual(rawLayer->getTextOffset(), propertyValue, @"Setting textOffset to a constant value expression should update text-offset."); XCTAssertEqualObjects(layer.textOffset, constantExpression, @@ -1542,7 +1542,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal({ 1, 1 }))) ); } - + XCTAssertEqual(rawLayer->getTextOffset(), propertyValue, @"Setting textOffset to a camera-data expression should update text-offset."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -1696,7 +1696,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.textRotation = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextRotate(), propertyValue, @"Setting textRotation to a constant value expression should update text-rotate."); XCTAssertEqualObjects(layer.textRotation, constantExpression, @@ -1743,7 +1743,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextRotate(), propertyValue, @"Setting textRotation to a camera-data expression should update text-rotate."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -1809,7 +1809,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"'lowercase'"]; layer.textTransform = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { mbgl::style::TextTransformType::Lowercase }; + mbgl::style::PropertyValue propertyValue = { mbgl::style::TextTransformType::Lowercase }; XCTAssertEqual(rawLayer->getTextTransform(), propertyValue, @"Setting textTransform to a constant value expression should update text-transform."); XCTAssertEqualObjects(layer.textTransform, constantExpression, @@ -1847,7 +1847,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.iconColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getIconColor(), propertyValue, @"Setting iconColor to a constant value expression should update icon-color."); XCTAssertEqualObjects(layer.iconColor, constantExpression, @@ -1894,7 +1894,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) ); } - + XCTAssertEqual(rawLayer->getIconColor(), propertyValue, @"Setting iconColor to a camera-data expression should update icon-color."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -1925,7 +1925,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.iconHaloBlur = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue, @"Setting iconHaloBlur to a constant value expression should update icon-halo-blur."); XCTAssertEqualObjects(layer.iconHaloBlur, constantExpression, @@ -1972,7 +1972,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getIconHaloBlur(), propertyValue, @"Setting iconHaloBlur to a camera-data expression should update icon-halo-blur."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2003,7 +2003,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.iconHaloColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue, @"Setting iconHaloColor to a constant value expression should update icon-halo-color."); XCTAssertEqualObjects(layer.iconHaloColor, constantExpression, @@ -2050,7 +2050,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) ); } - + XCTAssertEqual(rawLayer->getIconHaloColor(), propertyValue, @"Setting iconHaloColor to a camera-data expression should update icon-halo-color."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2081,7 +2081,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.iconHaloWidth = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue, @"Setting iconHaloWidth to a constant value expression should update icon-halo-width."); XCTAssertEqualObjects(layer.iconHaloWidth, constantExpression, @@ -2128,7 +2128,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getIconHaloWidth(), propertyValue, @"Setting iconHaloWidth to a camera-data expression should update icon-halo-width."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2159,7 +2159,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.iconOpacity = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue, @"Setting iconOpacity to a constant value expression should update icon-opacity."); XCTAssertEqualObjects(layer.iconOpacity, constantExpression, @@ -2206,7 +2206,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getIconOpacity(), propertyValue, @"Setting iconOpacity to a camera-data expression should update icon-opacity."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2331,7 +2331,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.textColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getTextColor(), propertyValue, @"Setting textColor to a constant value expression should update text-color."); XCTAssertEqualObjects(layer.textColor, constantExpression, @@ -2378,7 +2378,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) ); } - + XCTAssertEqual(rawLayer->getTextColor(), propertyValue, @"Setting textColor to a camera-data expression should update text-color."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2409,7 +2409,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.textHaloBlur = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue, @"Setting textHaloBlur to a constant value expression should update text-halo-blur."); XCTAssertEqualObjects(layer.textHaloBlur, constantExpression, @@ -2456,7 +2456,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextHaloBlur(), propertyValue, @"Setting textHaloBlur to a camera-data expression should update text-halo-blur."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2487,7 +2487,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"%@", [MGLColor redColor]]; layer.textHaloColor = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { { 1, 0, 0, 1 } }; + mbgl::style::PropertyValue propertyValue = { { 1, 0, 0, 1 } }; XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue, @"Setting textHaloColor to a constant value expression should update text-halo-color."); XCTAssertEqualObjects(layer.textHaloColor, constantExpression, @@ -2534,7 +2534,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(mbgl::Color(1, 0, 0, 1)))) ); } - + XCTAssertEqual(rawLayer->getTextHaloColor(), propertyValue, @"Setting textHaloColor to a camera-data expression should update text-halo-color."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2565,7 +2565,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.textHaloWidth = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue, @"Setting textHaloWidth to a constant value expression should update text-halo-width."); XCTAssertEqualObjects(layer.textHaloWidth, constantExpression, @@ -2612,7 +2612,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextHaloWidth(), propertyValue, @"Setting textHaloWidth to a camera-data expression should update text-halo-width."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; @@ -2643,7 +2643,7 @@ NSExpression *constantExpression = [NSExpression expressionWithFormat:@"1"]; layer.textOpacity = constantExpression; - mbgl::style::DataDrivenPropertyValue propertyValue = { 1.0 }; + mbgl::style::PropertyValue propertyValue = { 1.0 }; XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue, @"Setting textOpacity to a constant value expression should update text-opacity."); XCTAssertEqualObjects(layer.textOpacity, constantExpression, @@ -2690,7 +2690,7 @@ interpolate(linear(), zoom(), 10.0, interpolate(linear(), number(get("keyName")), 18.0, literal(1.0))) ); } - + XCTAssertEqual(rawLayer->getTextOpacity(), propertyValue, @"Setting textOpacity to a camera-data expression should update text-opacity."); pedanticFunctionExpression = [NSExpression expressionWithFormat:@"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", @{@10: pedanticFunctionExpression}]; diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index c92d25b7ef..db37a9b96f 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -96,9 +96,6 @@ global.paintPropertyType = function (property, type) { global.propertyValueType = function (property) { switch (property['property-type']) { - case 'data-driven': - case 'cross-faded-data-driven': - return `DataDrivenPropertyValue<${evaluatedType(property)}>`; case 'color-ramp': return `ColorRampPropertyValue`; default: diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp index 07d07ff0dd..d73abd4fe1 100644 --- a/src/mbgl/programs/symbol_program.cpp +++ b/src/mbgl/programs/symbol_program.cpp @@ -14,7 +14,7 @@ using namespace style; static_assert(sizeof(SymbolLayoutVertex) == 16, "expected SymbolLayoutVertex size"); std::unique_ptr SymbolSizeBinder::create(const float tileZoom, - const style::DataDrivenPropertyValue& sizeProperty, + const style::PropertyValue& sizeProperty, const float defaultValue) { return sizeProperty.match( [&] (const Undefined& value) -> std::unique_ptr { @@ -46,7 +46,7 @@ Values makeValues(const bool isText, const float symbolFadeChange, Args&&... args) { std::array extrudeScale; - + if (values.pitchAlignment == AlignmentType::Map) { extrudeScale.fill(tile.id.pixelsToTileUnits(1, state.getZoom())); } else { @@ -59,7 +59,7 @@ Values makeValues(const bool isText, const float pixelsToTileUnits = tile.id.pixelsToTileUnits(1.0, state.getZoom()); const bool pitchWithMap = values.pitchAlignment == style::AlignmentType::Map; const bool rotateWithMap = values.rotationAlignment == style::AlignmentType::Map; - + // Line label rotation happens in `updateLineLabels` // Pitched point labels are automatically rotated by the labelPlaneMatrix projection // Unpitched point labels need to have their rotation applied after projection @@ -75,7 +75,7 @@ Values makeValues(const bool isText, } mat4 glCoordMatrix = getGlCoordMatrix(tile.matrix, pitchWithMap, rotateWithMap, state, pixelsToTileUnits); - + return Values { uniforms::u_matrix::Value{ tile.translatedMatrix(values.translate, values.translateAnchor, @@ -137,7 +137,7 @@ typename SymbolSDFProgram::UniformValues SymbolSDFProgram::UniformValues>( isText, values, diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index 653fce9d4c..0378cc0970 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -92,7 +92,7 @@ struct SymbolOpacityAttributes : gl::Attributes { }; } }; - + struct ZoomEvaluatedSize { bool isZoomConstant; bool isFeatureConstant; @@ -114,9 +114,9 @@ public: uniforms::u_size_t, uniforms::u_size>; using UniformValues = Uniforms::Values; - + static std::unique_ptr create(const float tileZoom, - const style::DataDrivenPropertyValue& sizeProperty, + const style::PropertyValue& sizeProperty, const float defaultValue); virtual Range getVertexSizeData(const GeometryTileFeature& feature) = 0; @@ -138,10 +138,10 @@ class ConstantSymbolSizeBinder final : public SymbolSizeBinder { public: ConstantSymbolSizeBinder(const float /*tileZoom*/, const float& size, const float /*defaultValue*/) : layoutSize(size) {} - + ConstantSymbolSizeBinder(const float /*tileZoom*/, const style::Undefined&, const float defaultValue) : layoutSize(defaultValue) {} - + ConstantSymbolSizeBinder(const float tileZoom, const style::PropertyExpression& expression_, const float /*defaultValue*/) : layoutSize(expression_.evaluate(tileZoom + 1)), expression(expression_) { @@ -151,9 +151,9 @@ public: Range { expression_.evaluate(zoomLevels.min), expression_.evaluate(zoomLevels.max) } ); } - + Range getVertexSizeData(const GeometryTileFeature&) override { return { 0.0f, 0.0f }; }; - + ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override { float size = layoutSize; bool isZoomConstant = !(coveringRanges || expression); @@ -177,7 +177,7 @@ public: const float unused = 0.0f; return { isZoomConstant, true, unused, size, layoutSize }; } - + float layoutSize; optional, Range>> coveringRanges; optional> expression; @@ -188,7 +188,7 @@ public: using Vertex = gl::detail::Vertex>; using VertexVector = gl::VertexVector; using VertexBuffer = gl::VertexBuffer; - + SourceFunctionSymbolSizeBinder(const float /*tileZoom*/, style::PropertyExpression expression_, const float defaultValue_) : expression(std::move(expression_)), defaultValue(defaultValue_) { @@ -198,19 +198,19 @@ public: const float size = expression.evaluate(feature, defaultValue); return { size, size }; }; - + ZoomEvaluatedSize evaluateForZoom(float) const override { const float unused = 0.0f; return { true, false, unused, unused, unused }; } - + style::PropertyExpression expression; const float defaultValue; }; class CompositeFunctionSymbolSizeBinder final : public SymbolSizeBinder { public: - + CompositeFunctionSymbolSizeBinder(const float tileZoom, style::PropertyExpression expression_, const float defaultValue_) : expression(std::move(expression_)), defaultValue(defaultValue_), @@ -224,7 +224,7 @@ public: expression.evaluate(coveringZoomStops.max, feature, defaultValue) }; }; - + ZoomEvaluatedSize evaluateForZoom(float currentZoom) const override { float sizeInterpolationT = util::clamp( expression.interpolationFactor(coveringZoomStops, currentZoom), @@ -234,7 +234,7 @@ public: const float unused = 0.0f; return { false, false, sizeInterpolationT, unused, unused }; } - + style::PropertyExpression expression; const float defaultValue; float layoutZoom; @@ -251,7 +251,7 @@ class SymbolProgram { public: using LayoutAttributes = LayoutAttrs; using LayoutVertex = typename LayoutAttributes::Vertex; - + using LayoutAndSizeAttributes = gl::ConcatenateAttributes>; using PaintProperties = PaintProps; @@ -421,11 +421,11 @@ public: uniforms::u_gamma_scale, uniforms::u_is_halo>, PaintProperties>; - + using UniformValues = typename BaseProgram::UniformValues; - - + + using BaseProgram::BaseProgram; static UniformValues uniformValues(const bool isText, diff --git a/src/mbgl/renderer/buckets/symbol_bucket.cpp b/src/mbgl/renderer/buckets/symbol_bucket.cpp index 0a1530ae74..027e864be5 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.cpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.cpp @@ -12,8 +12,8 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo const std::map>& layerPaintProperties, - const style::DataDrivenPropertyValue& textSize, - const style::DataDrivenPropertyValue& iconSize, + const style::PropertyValue& textSize, + const style::PropertyValue& iconSize, float zoom, bool sdfIcons_, bool iconsNeedLinear_, @@ -29,7 +29,7 @@ SymbolBucket::SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated layo symbolInstances(std::move(symbolInstances_)), textSizeBinder(SymbolSizeBinder::create(zoom, textSize, TextSize::defaultValue())), iconSizeBinder(SymbolSizeBinder::create(zoom, iconSize, IconSize::defaultValue())) { - + for (const auto& pair : layerPaintProperties) { paintPropertyBinders.emplace( std::piecewise_construct, @@ -49,7 +49,7 @@ void SymbolBucket::upload(gl::Context& context) { } else if (!sortUploaded) { context.updateIndexBuffer(*text.indexBuffer, std::move(text.triangles)); } - + if (!dynamicUploaded) { text.dynamicVertexBuffer = context.createVertexBuffer(std::move(text.dynamicVertices), gl::BufferUsage::StreamDraw); } @@ -94,7 +94,7 @@ void SymbolBucket::upload(gl::Context& context) { } } } - + if (hasCollisionCircleData()) { if (!staticUploaded) { collisionCircle.indexBuffer = context.createIndexBuffer(std::move(collisionCircle.triangles)); @@ -115,7 +115,7 @@ void SymbolBucket::upload(gl::Context& context) { pair.second.second.upload(context); } } - + uploaded = true; staticUploaded = true; placementChangesUploaded = true; @@ -164,7 +164,7 @@ void SymbolBucket::sortFeatures(const float angle) { if (sortedAngle && *sortedAngle == angle) { return; } - + sortedAngle = angle; // The current approach to sorting doesn't sort across segments so don't try. @@ -172,7 +172,7 @@ void SymbolBucket::sortFeatures(const float angle) { if (text.segments.size() > 1 || icon.segments.size() > 1) { return; } - + sortUploaded = false; uploaded = false; @@ -186,7 +186,7 @@ void SymbolBucket::sortFeatures(const float angle) { for (size_t i = 0; i < symbolInstances.size(); i++) { symbolInstanceIndexes.push_back(i); } - + const float sin = std::sin(angle); const float cos = std::cos(angle); @@ -205,7 +205,7 @@ void SymbolBucket::sortFeatures(const float angle) { featureSortOrder = std::make_unique>(); featureSortOrder->reserve(symbolInstanceIndexes.size()); - + for (auto i : symbolInstanceIndexes) { const SymbolInstance& symbolInstance = symbolInstances[i]; featureSortOrder->push_back(symbolInstance.dataFeatureIndex); diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp index 4f01cf4e1c..5addff40b2 100644 --- a/src/mbgl/renderer/buckets/symbol_bucket.hpp +++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp @@ -41,8 +41,8 @@ class SymbolBucket : public Bucket { public: SymbolBucket(style::SymbolLayoutProperties::PossiblyEvaluated, const std::map>&, - const style::DataDrivenPropertyValue& textSize, - const style::DataDrivenPropertyValue& iconSize, + const style::PropertyValue& textSize, + const style::PropertyValue& iconSize, float zoom, bool sdfIcons, bool iconsNeedLinear, @@ -56,7 +56,7 @@ public: bool hasIconData() const; bool hasCollisionBoxData() const; bool hasCollisionCircleData() const; - + void updateOpacity(); void sortFeatures(const float angle); @@ -64,9 +64,9 @@ public: const bool sdfIcons; const bool iconsNeedLinear; const bool sortFeaturesByY; - + const std::string bucketLeaderID; - + optional sortedAngle; bool staticUploaded = false; @@ -79,7 +79,7 @@ public: std::map> paintPropertyBinders; - + std::unique_ptr textSizeBinder; struct TextBuffer { @@ -95,9 +95,9 @@ public: optional> opacityVertexBuffer; optional> indexBuffer; } text; - + std::unique_ptr iconSizeBinder; - + struct IconBuffer { gl::VertexVector vertices; gl::VertexVector dynamicVertices; @@ -126,7 +126,7 @@ public: gl::IndexVector lines; optional> indexBuffer; } collisionBox; - + struct CollisionCircleBuffer : public CollisionBuffer { gl::IndexVector triangles; optional> indexBuffer; @@ -134,7 +134,7 @@ public: uint32_t bucketInstanceId = 0; bool justReloaded = false; - + std::shared_ptr> featureSortOrder; }; diff --git a/src/mbgl/style/conversion/color_ramp_property_value.cpp b/src/mbgl/style/conversion/color_ramp_property_value.cpp index e792cf3fe4..f29438b6a2 100644 --- a/src/mbgl/style/conversion/color_ramp_property_value.cpp +++ b/src/mbgl/style/conversion/color_ramp_property_value.cpp @@ -10,7 +10,7 @@ namespace mbgl { namespace style { namespace conversion { -optional Converter::operator()(const Convertible& value, Error& error, bool) const { +optional Converter::operator()(const Convertible& value, Error& error, bool, bool) const { using namespace mbgl::style::expression; if (isUndefined(value)) { return ColorRampPropertyValue(); diff --git a/src/mbgl/style/conversion/light.cpp b/src/mbgl/style/conversion/light.cpp index 0a68f2396f..7b96c89a1c 100644 --- a/src/mbgl/style/conversion/light.cpp +++ b/src/mbgl/style/conversion/light.cpp @@ -18,7 +18,7 @@ optional Converter::operator()(const Convertible& value, Error& er const auto anchor = objectMember(value, "anchor"); if (anchor) { optional> convertedAnchor = - convert>(*anchor, error, false); + convert>(*anchor, error, false, false); if (convertedAnchor) { light.setAnchor(*convertedAnchor); @@ -41,7 +41,7 @@ optional Converter::operator()(const Convertible& value, Error& er const auto color = objectMember(value, "color"); if (color) { optional> convertedColor = - convert>(*color, error, false); + convert>(*color, error, false, false); if (convertedColor) { light.setColor(*convertedColor); @@ -64,7 +64,7 @@ optional Converter::operator()(const Convertible& value, Error& er const auto position = objectMember(value, "position"); if (position) { optional> convertedPosition = - convert>(*position, error, false); + convert>(*position, error, false, false); if (convertedPosition) { light.setPosition(*convertedPosition); @@ -87,7 +87,7 @@ optional Converter::operator()(const Convertible& value, Error& er const auto intensity = objectMember(value, "intensity"); if (intensity) { optional> convertedIntensity = - convert>(*intensity, error, false); + convert>(*intensity, error, false, false); if (convertedIntensity) { light.setIntensity(*convertedIntensity); diff --git a/src/mbgl/style/conversion/make_property_setters.hpp b/src/mbgl/style/conversion/make_property_setters.hpp index 64826106f0..ada0d53002 100644 --- a/src/mbgl/style/conversion/make_property_setters.hpp +++ b/src/mbgl/style/conversion/make_property_setters.hpp @@ -26,47 +26,47 @@ inline auto makeLayoutPropertySetters() { result["visibility"] = &setVisibility; - result["line-cap"] = &setProperty, &LineLayer::setLineCap>; - result["line-join"] = &setProperty, &LineLayer::setLineJoin>; - result["line-miter-limit"] = &setProperty, &LineLayer::setLineMiterLimit>; - result["line-round-limit"] = &setProperty, &LineLayer::setLineRoundLimit>; - - result["symbol-placement"] = &setProperty, &SymbolLayer::setSymbolPlacement>; - result["symbol-spacing"] = &setProperty, &SymbolLayer::setSymbolSpacing>; - result["symbol-avoid-edges"] = &setProperty, &SymbolLayer::setSymbolAvoidEdges>; - result["icon-allow-overlap"] = &setProperty, &SymbolLayer::setIconAllowOverlap>; - result["icon-ignore-placement"] = &setProperty, &SymbolLayer::setIconIgnorePlacement>; - result["icon-optional"] = &setProperty, &SymbolLayer::setIconOptional>; - result["icon-rotation-alignment"] = &setProperty, &SymbolLayer::setIconRotationAlignment>; - result["icon-size"] = &setProperty, &SymbolLayer::setIconSize>; - result["icon-text-fit"] = &setProperty, &SymbolLayer::setIconTextFit>; - result["icon-text-fit-padding"] = &setProperty>, &SymbolLayer::setIconTextFitPadding>; - result["icon-image"] = &setProperty, &SymbolLayer::setIconImage, true>; - result["icon-rotate"] = &setProperty, &SymbolLayer::setIconRotate>; - result["icon-padding"] = &setProperty, &SymbolLayer::setIconPadding>; - result["icon-keep-upright"] = &setProperty, &SymbolLayer::setIconKeepUpright>; - result["icon-offset"] = &setProperty>, &SymbolLayer::setIconOffset>; - result["icon-anchor"] = &setProperty, &SymbolLayer::setIconAnchor>; - result["icon-pitch-alignment"] = &setProperty, &SymbolLayer::setIconPitchAlignment>; - result["text-pitch-alignment"] = &setProperty, &SymbolLayer::setTextPitchAlignment>; - result["text-rotation-alignment"] = &setProperty, &SymbolLayer::setTextRotationAlignment>; - result["text-field"] = &setProperty, &SymbolLayer::setTextField, true>; - result["text-font"] = &setProperty>, &SymbolLayer::setTextFont>; - result["text-size"] = &setProperty, &SymbolLayer::setTextSize>; - result["text-max-width"] = &setProperty, &SymbolLayer::setTextMaxWidth>; - result["text-line-height"] = &setProperty, &SymbolLayer::setTextLineHeight>; - result["text-letter-spacing"] = &setProperty, &SymbolLayer::setTextLetterSpacing>; - result["text-justify"] = &setProperty, &SymbolLayer::setTextJustify>; - result["text-anchor"] = &setProperty, &SymbolLayer::setTextAnchor>; - result["text-max-angle"] = &setProperty, &SymbolLayer::setTextMaxAngle>; - result["text-rotate"] = &setProperty, &SymbolLayer::setTextRotate>; - result["text-padding"] = &setProperty, &SymbolLayer::setTextPadding>; - result["text-keep-upright"] = &setProperty, &SymbolLayer::setTextKeepUpright>; - result["text-transform"] = &setProperty, &SymbolLayer::setTextTransform>; - result["text-offset"] = &setProperty>, &SymbolLayer::setTextOffset>; - result["text-allow-overlap"] = &setProperty, &SymbolLayer::setTextAllowOverlap>; - result["text-ignore-placement"] = &setProperty, &SymbolLayer::setTextIgnorePlacement>; - result["text-optional"] = &setProperty, &SymbolLayer::setTextOptional>; + result["line-cap"] = &setProperty, &LineLayer::setLineCap, false, false>; + result["line-join"] = &setProperty, &LineLayer::setLineJoin, true, false>; + result["line-miter-limit"] = &setProperty, &LineLayer::setLineMiterLimit, false, false>; + result["line-round-limit"] = &setProperty, &LineLayer::setLineRoundLimit, false, false>; + + result["symbol-placement"] = &setProperty, &SymbolLayer::setSymbolPlacement, false, false>; + result["symbol-spacing"] = &setProperty, &SymbolLayer::setSymbolSpacing, false, false>; + result["symbol-avoid-edges"] = &setProperty, &SymbolLayer::setSymbolAvoidEdges, false, false>; + result["icon-allow-overlap"] = &setProperty, &SymbolLayer::setIconAllowOverlap, false, false>; + result["icon-ignore-placement"] = &setProperty, &SymbolLayer::setIconIgnorePlacement, false, false>; + result["icon-optional"] = &setProperty, &SymbolLayer::setIconOptional, false, false>; + result["icon-rotation-alignment"] = &setProperty, &SymbolLayer::setIconRotationAlignment, false, false>; + result["icon-size"] = &setProperty, &SymbolLayer::setIconSize, true, false>; + result["icon-text-fit"] = &setProperty, &SymbolLayer::setIconTextFit, false, false>; + result["icon-text-fit-padding"] = &setProperty>, &SymbolLayer::setIconTextFitPadding, false, false>; + result["icon-image"] = &setProperty, &SymbolLayer::setIconImage, true, true>; + result["icon-rotate"] = &setProperty, &SymbolLayer::setIconRotate, true, false>; + result["icon-padding"] = &setProperty, &SymbolLayer::setIconPadding, false, false>; + result["icon-keep-upright"] = &setProperty, &SymbolLayer::setIconKeepUpright, false, false>; + result["icon-offset"] = &setProperty>, &SymbolLayer::setIconOffset, true, false>; + result["icon-anchor"] = &setProperty, &SymbolLayer::setIconAnchor, true, false>; + result["icon-pitch-alignment"] = &setProperty, &SymbolLayer::setIconPitchAlignment, false, false>; + result["text-pitch-alignment"] = &setProperty, &SymbolLayer::setTextPitchAlignment, false, false>; + result["text-rotation-alignment"] = &setProperty, &SymbolLayer::setTextRotationAlignment, false, false>; + result["text-field"] = &setProperty, &SymbolLayer::setTextField, true, true>; + result["text-font"] = &setProperty>, &SymbolLayer::setTextFont, true, false>; + result["text-size"] = &setProperty, &SymbolLayer::setTextSize, true, false>; + result["text-max-width"] = &setProperty, &SymbolLayer::setTextMaxWidth, true, false>; + result["text-line-height"] = &setProperty, &SymbolLayer::setTextLineHeight, false, false>; + result["text-letter-spacing"] = &setProperty, &SymbolLayer::setTextLetterSpacing, true, false>; + result["text-justify"] = &setProperty, &SymbolLayer::setTextJustify, true, false>; + result["text-anchor"] = &setProperty, &SymbolLayer::setTextAnchor, true, false>; + result["text-max-angle"] = &setProperty, &SymbolLayer::setTextMaxAngle, false, false>; + result["text-rotate"] = &setProperty, &SymbolLayer::setTextRotate, true, false>; + result["text-padding"] = &setProperty, &SymbolLayer::setTextPadding, false, false>; + result["text-keep-upright"] = &setProperty, &SymbolLayer::setTextKeepUpright, false, false>; + result["text-transform"] = &setProperty, &SymbolLayer::setTextTransform, true, false>; + result["text-offset"] = &setProperty>, &SymbolLayer::setTextOffset, true, false>; + result["text-allow-overlap"] = &setProperty, &SymbolLayer::setTextAllowOverlap, false, false>; + result["text-ignore-placement"] = &setProperty, &SymbolLayer::setTextIgnorePlacement, false, false>; + result["text-optional"] = &setProperty, &SymbolLayer::setTextOptional, false, false>; @@ -80,155 +80,155 @@ inline auto makeLayoutPropertySetters() { inline auto makePaintPropertySetters() { std::unordered_map result; - result["fill-antialias"] = &setProperty, &FillLayer::setFillAntialias>; + result["fill-antialias"] = &setProperty, &FillLayer::setFillAntialias, false, false>; result["fill-antialias-transition"] = &setTransition; - result["fill-opacity"] = &setProperty, &FillLayer::setFillOpacity>; + result["fill-opacity"] = &setProperty, &FillLayer::setFillOpacity, true, false>; result["fill-opacity-transition"] = &setTransition; - result["fill-color"] = &setProperty, &FillLayer::setFillColor>; + result["fill-color"] = &setProperty, &FillLayer::setFillColor, true, false>; result["fill-color-transition"] = &setTransition; - result["fill-outline-color"] = &setProperty, &FillLayer::setFillOutlineColor>; + result["fill-outline-color"] = &setProperty, &FillLayer::setFillOutlineColor, true, false>; result["fill-outline-color-transition"] = &setTransition; - result["fill-translate"] = &setProperty>, &FillLayer::setFillTranslate>; + result["fill-translate"] = &setProperty>, &FillLayer::setFillTranslate, false, false>; result["fill-translate-transition"] = &setTransition; - result["fill-translate-anchor"] = &setProperty, &FillLayer::setFillTranslateAnchor>; + result["fill-translate-anchor"] = &setProperty, &FillLayer::setFillTranslateAnchor, false, false>; result["fill-translate-anchor-transition"] = &setTransition; - result["fill-pattern"] = &setProperty, &FillLayer::setFillPattern>; + result["fill-pattern"] = &setProperty, &FillLayer::setFillPattern, false, false>; result["fill-pattern-transition"] = &setTransition; - result["line-opacity"] = &setProperty, &LineLayer::setLineOpacity>; + result["line-opacity"] = &setProperty, &LineLayer::setLineOpacity, true, false>; result["line-opacity-transition"] = &setTransition; - result["line-color"] = &setProperty, &LineLayer::setLineColor>; + result["line-color"] = &setProperty, &LineLayer::setLineColor, true, false>; result["line-color-transition"] = &setTransition; - result["line-translate"] = &setProperty>, &LineLayer::setLineTranslate>; + result["line-translate"] = &setProperty>, &LineLayer::setLineTranslate, false, false>; result["line-translate-transition"] = &setTransition; - result["line-translate-anchor"] = &setProperty, &LineLayer::setLineTranslateAnchor>; + result["line-translate-anchor"] = &setProperty, &LineLayer::setLineTranslateAnchor, false, false>; result["line-translate-anchor-transition"] = &setTransition; - result["line-width"] = &setProperty, &LineLayer::setLineWidth>; + result["line-width"] = &setProperty, &LineLayer::setLineWidth, true, false>; result["line-width-transition"] = &setTransition; - result["line-gap-width"] = &setProperty, &LineLayer::setLineGapWidth>; + result["line-gap-width"] = &setProperty, &LineLayer::setLineGapWidth, true, false>; result["line-gap-width-transition"] = &setTransition; - result["line-offset"] = &setProperty, &LineLayer::setLineOffset>; + result["line-offset"] = &setProperty, &LineLayer::setLineOffset, true, false>; result["line-offset-transition"] = &setTransition; - result["line-blur"] = &setProperty, &LineLayer::setLineBlur>; + result["line-blur"] = &setProperty, &LineLayer::setLineBlur, true, false>; result["line-blur-transition"] = &setTransition; - result["line-dasharray"] = &setProperty>, &LineLayer::setLineDasharray>; + result["line-dasharray"] = &setProperty>, &LineLayer::setLineDasharray, false, false>; result["line-dasharray-transition"] = &setTransition; - result["line-pattern"] = &setProperty, &LineLayer::setLinePattern>; + result["line-pattern"] = &setProperty, &LineLayer::setLinePattern, false, false>; result["line-pattern-transition"] = &setTransition; - result["icon-opacity"] = &setProperty, &SymbolLayer::setIconOpacity>; + result["icon-opacity"] = &setProperty, &SymbolLayer::setIconOpacity, true, false>; result["icon-opacity-transition"] = &setTransition; - result["icon-color"] = &setProperty, &SymbolLayer::setIconColor>; + result["icon-color"] = &setProperty, &SymbolLayer::setIconColor, true, false>; result["icon-color-transition"] = &setTransition; - result["icon-halo-color"] = &setProperty, &SymbolLayer::setIconHaloColor>; + result["icon-halo-color"] = &setProperty, &SymbolLayer::setIconHaloColor, true, false>; result["icon-halo-color-transition"] = &setTransition; - result["icon-halo-width"] = &setProperty, &SymbolLayer::setIconHaloWidth>; + result["icon-halo-width"] = &setProperty, &SymbolLayer::setIconHaloWidth, true, false>; result["icon-halo-width-transition"] = &setTransition; - result["icon-halo-blur"] = &setProperty, &SymbolLayer::setIconHaloBlur>; + result["icon-halo-blur"] = &setProperty, &SymbolLayer::setIconHaloBlur, true, false>; result["icon-halo-blur-transition"] = &setTransition; - result["icon-translate"] = &setProperty>, &SymbolLayer::setIconTranslate>; + result["icon-translate"] = &setProperty>, &SymbolLayer::setIconTranslate, false, false>; result["icon-translate-transition"] = &setTransition; - result["icon-translate-anchor"] = &setProperty, &SymbolLayer::setIconTranslateAnchor>; + result["icon-translate-anchor"] = &setProperty, &SymbolLayer::setIconTranslateAnchor, false, false>; result["icon-translate-anchor-transition"] = &setTransition; - result["text-opacity"] = &setProperty, &SymbolLayer::setTextOpacity>; + result["text-opacity"] = &setProperty, &SymbolLayer::setTextOpacity, true, false>; result["text-opacity-transition"] = &setTransition; - result["text-color"] = &setProperty, &SymbolLayer::setTextColor>; + result["text-color"] = &setProperty, &SymbolLayer::setTextColor, true, false>; result["text-color-transition"] = &setTransition; - result["text-halo-color"] = &setProperty, &SymbolLayer::setTextHaloColor>; + result["text-halo-color"] = &setProperty, &SymbolLayer::setTextHaloColor, true, false>; result["text-halo-color-transition"] = &setTransition; - result["text-halo-width"] = &setProperty, &SymbolLayer::setTextHaloWidth>; + result["text-halo-width"] = &setProperty, &SymbolLayer::setTextHaloWidth, true, false>; result["text-halo-width-transition"] = &setTransition; - result["text-halo-blur"] = &setProperty, &SymbolLayer::setTextHaloBlur>; + result["text-halo-blur"] = &setProperty, &SymbolLayer::setTextHaloBlur, true, false>; result["text-halo-blur-transition"] = &setTransition; - result["text-translate"] = &setProperty>, &SymbolLayer::setTextTranslate>; + result["text-translate"] = &setProperty>, &SymbolLayer::setTextTranslate, false, false>; result["text-translate-transition"] = &setTransition; - result["text-translate-anchor"] = &setProperty, &SymbolLayer::setTextTranslateAnchor>; + result["text-translate-anchor"] = &setProperty, &SymbolLayer::setTextTranslateAnchor, false, false>; result["text-translate-anchor-transition"] = &setTransition; - result["circle-radius"] = &setProperty, &CircleLayer::setCircleRadius>; + result["circle-radius"] = &setProperty, &CircleLayer::setCircleRadius, true, false>; result["circle-radius-transition"] = &setTransition; - result["circle-color"] = &setProperty, &CircleLayer::setCircleColor>; + result["circle-color"] = &setProperty, &CircleLayer::setCircleColor, true, false>; result["circle-color-transition"] = &setTransition; - result["circle-blur"] = &setProperty, &CircleLayer::setCircleBlur>; + result["circle-blur"] = &setProperty, &CircleLayer::setCircleBlur, true, false>; result["circle-blur-transition"] = &setTransition; - result["circle-opacity"] = &setProperty, &CircleLayer::setCircleOpacity>; + result["circle-opacity"] = &setProperty, &CircleLayer::setCircleOpacity, true, false>; result["circle-opacity-transition"] = &setTransition; - result["circle-translate"] = &setProperty>, &CircleLayer::setCircleTranslate>; + result["circle-translate"] = &setProperty>, &CircleLayer::setCircleTranslate, false, false>; result["circle-translate-transition"] = &setTransition; - result["circle-translate-anchor"] = &setProperty, &CircleLayer::setCircleTranslateAnchor>; + result["circle-translate-anchor"] = &setProperty, &CircleLayer::setCircleTranslateAnchor, false, false>; result["circle-translate-anchor-transition"] = &setTransition; - result["circle-pitch-scale"] = &setProperty, &CircleLayer::setCirclePitchScale>; + result["circle-pitch-scale"] = &setProperty, &CircleLayer::setCirclePitchScale, false, false>; result["circle-pitch-scale-transition"] = &setTransition; - result["circle-pitch-alignment"] = &setProperty, &CircleLayer::setCirclePitchAlignment>; + result["circle-pitch-alignment"] = &setProperty, &CircleLayer::setCirclePitchAlignment, false, false>; result["circle-pitch-alignment-transition"] = &setTransition; - result["circle-stroke-width"] = &setProperty, &CircleLayer::setCircleStrokeWidth>; + result["circle-stroke-width"] = &setProperty, &CircleLayer::setCircleStrokeWidth, true, false>; result["circle-stroke-width-transition"] = &setTransition; - result["circle-stroke-color"] = &setProperty, &CircleLayer::setCircleStrokeColor>; + result["circle-stroke-color"] = &setProperty, &CircleLayer::setCircleStrokeColor, true, false>; result["circle-stroke-color-transition"] = &setTransition; - result["circle-stroke-opacity"] = &setProperty, &CircleLayer::setCircleStrokeOpacity>; + result["circle-stroke-opacity"] = &setProperty, &CircleLayer::setCircleStrokeOpacity, true, false>; result["circle-stroke-opacity-transition"] = &setTransition; - result["heatmap-radius"] = &setProperty, &HeatmapLayer::setHeatmapRadius>; + result["heatmap-radius"] = &setProperty, &HeatmapLayer::setHeatmapRadius, true, false>; result["heatmap-radius-transition"] = &setTransition; - result["heatmap-weight"] = &setProperty, &HeatmapLayer::setHeatmapWeight>; + result["heatmap-weight"] = &setProperty, &HeatmapLayer::setHeatmapWeight, true, false>; result["heatmap-weight-transition"] = &setTransition; - result["heatmap-intensity"] = &setProperty, &HeatmapLayer::setHeatmapIntensity>; + result["heatmap-intensity"] = &setProperty, &HeatmapLayer::setHeatmapIntensity, false, false>; result["heatmap-intensity-transition"] = &setTransition; - result["heatmap-color"] = &setProperty; + result["heatmap-color"] = &setProperty; result["heatmap-color-transition"] = &setTransition; - result["heatmap-opacity"] = &setProperty, &HeatmapLayer::setHeatmapOpacity>; + result["heatmap-opacity"] = &setProperty, &HeatmapLayer::setHeatmapOpacity, false, false>; result["heatmap-opacity-transition"] = &setTransition; - result["fill-extrusion-opacity"] = &setProperty, &FillExtrusionLayer::setFillExtrusionOpacity>; + result["fill-extrusion-opacity"] = &setProperty, &FillExtrusionLayer::setFillExtrusionOpacity, false, false>; result["fill-extrusion-opacity-transition"] = &setTransition; - result["fill-extrusion-color"] = &setProperty, &FillExtrusionLayer::setFillExtrusionColor>; + result["fill-extrusion-color"] = &setProperty, &FillExtrusionLayer::setFillExtrusionColor, true, false>; result["fill-extrusion-color-transition"] = &setTransition; - result["fill-extrusion-translate"] = &setProperty>, &FillExtrusionLayer::setFillExtrusionTranslate>; + result["fill-extrusion-translate"] = &setProperty>, &FillExtrusionLayer::setFillExtrusionTranslate, false, false>; result["fill-extrusion-translate-transition"] = &setTransition; - result["fill-extrusion-translate-anchor"] = &setProperty, &FillExtrusionLayer::setFillExtrusionTranslateAnchor>; + result["fill-extrusion-translate-anchor"] = &setProperty, &FillExtrusionLayer::setFillExtrusionTranslateAnchor, false, false>; result["fill-extrusion-translate-anchor-transition"] = &setTransition; - result["fill-extrusion-pattern"] = &setProperty, &FillExtrusionLayer::setFillExtrusionPattern>; + result["fill-extrusion-pattern"] = &setProperty, &FillExtrusionLayer::setFillExtrusionPattern, false, false>; result["fill-extrusion-pattern-transition"] = &setTransition; - result["fill-extrusion-height"] = &setProperty, &FillExtrusionLayer::setFillExtrusionHeight>; + result["fill-extrusion-height"] = &setProperty, &FillExtrusionLayer::setFillExtrusionHeight, true, false>; result["fill-extrusion-height-transition"] = &setTransition; - result["fill-extrusion-base"] = &setProperty, &FillExtrusionLayer::setFillExtrusionBase>; + result["fill-extrusion-base"] = &setProperty, &FillExtrusionLayer::setFillExtrusionBase, true, false>; result["fill-extrusion-base-transition"] = &setTransition; - result["raster-opacity"] = &setProperty, &RasterLayer::setRasterOpacity>; + result["raster-opacity"] = &setProperty, &RasterLayer::setRasterOpacity, false, false>; result["raster-opacity-transition"] = &setTransition; - result["raster-hue-rotate"] = &setProperty, &RasterLayer::setRasterHueRotate>; + result["raster-hue-rotate"] = &setProperty, &RasterLayer::setRasterHueRotate, false, false>; result["raster-hue-rotate-transition"] = &setTransition; - result["raster-brightness-min"] = &setProperty, &RasterLayer::setRasterBrightnessMin>; + result["raster-brightness-min"] = &setProperty, &RasterLayer::setRasterBrightnessMin, false, false>; result["raster-brightness-min-transition"] = &setTransition; - result["raster-brightness-max"] = &setProperty, &RasterLayer::setRasterBrightnessMax>; + result["raster-brightness-max"] = &setProperty, &RasterLayer::setRasterBrightnessMax, false, false>; result["raster-brightness-max-transition"] = &setTransition; - result["raster-saturation"] = &setProperty, &RasterLayer::setRasterSaturation>; + result["raster-saturation"] = &setProperty, &RasterLayer::setRasterSaturation, false, false>; result["raster-saturation-transition"] = &setTransition; - result["raster-contrast"] = &setProperty, &RasterLayer::setRasterContrast>; + result["raster-contrast"] = &setProperty, &RasterLayer::setRasterContrast, false, false>; result["raster-contrast-transition"] = &setTransition; - result["raster-resampling"] = &setProperty, &RasterLayer::setRasterResampling>; + result["raster-resampling"] = &setProperty, &RasterLayer::setRasterResampling, false, false>; result["raster-resampling-transition"] = &setTransition; - result["raster-fade-duration"] = &setProperty, &RasterLayer::setRasterFadeDuration>; + result["raster-fade-duration"] = &setProperty, &RasterLayer::setRasterFadeDuration, false, false>; result["raster-fade-duration-transition"] = &setTransition; - result["hillshade-illumination-direction"] = &setProperty, &HillshadeLayer::setHillshadeIlluminationDirection>; + result["hillshade-illumination-direction"] = &setProperty, &HillshadeLayer::setHillshadeIlluminationDirection, false, false>; result["hillshade-illumination-direction-transition"] = &setTransition; - result["hillshade-illumination-anchor"] = &setProperty, &HillshadeLayer::setHillshadeIlluminationAnchor>; + result["hillshade-illumination-anchor"] = &setProperty, &HillshadeLayer::setHillshadeIlluminationAnchor, false, false>; result["hillshade-illumination-anchor-transition"] = &setTransition; - result["hillshade-exaggeration"] = &setProperty, &HillshadeLayer::setHillshadeExaggeration>; + result["hillshade-exaggeration"] = &setProperty, &HillshadeLayer::setHillshadeExaggeration, false, false>; result["hillshade-exaggeration-transition"] = &setTransition; - result["hillshade-shadow-color"] = &setProperty, &HillshadeLayer::setHillshadeShadowColor>; + result["hillshade-shadow-color"] = &setProperty, &HillshadeLayer::setHillshadeShadowColor, false, false>; result["hillshade-shadow-color-transition"] = &setTransition; - result["hillshade-highlight-color"] = &setProperty, &HillshadeLayer::setHillshadeHighlightColor>; + result["hillshade-highlight-color"] = &setProperty, &HillshadeLayer::setHillshadeHighlightColor, false, false>; result["hillshade-highlight-color-transition"] = &setTransition; - result["hillshade-accent-color"] = &setProperty, &HillshadeLayer::setHillshadeAccentColor>; + result["hillshade-accent-color"] = &setProperty, &HillshadeLayer::setHillshadeAccentColor, false, false>; result["hillshade-accent-color-transition"] = &setTransition; - result["background-color"] = &setProperty, &BackgroundLayer::setBackgroundColor>; + result["background-color"] = &setProperty, &BackgroundLayer::setBackgroundColor, false, false>; result["background-color-transition"] = &setTransition; - result["background-pattern"] = &setProperty, &BackgroundLayer::setBackgroundPattern>; + result["background-pattern"] = &setProperty, &BackgroundLayer::setBackgroundPattern, false, false>; result["background-pattern-transition"] = &setTransition; - result["background-opacity"] = &setProperty, &BackgroundLayer::setBackgroundOpacity>; + result["background-opacity"] = &setProperty, &BackgroundLayer::setBackgroundOpacity, false, false>; result["background-opacity-transition"] = &setTransition; return result; diff --git a/src/mbgl/style/conversion/make_property_setters.hpp.ejs b/src/mbgl/style/conversion/make_property_setters.hpp.ejs index 2b8925817d..fbf2f93fd6 100644 --- a/src/mbgl/style/conversion/make_property_setters.hpp.ejs +++ b/src/mbgl/style/conversion/make_property_setters.hpp.ejs @@ -21,7 +21,7 @@ inline auto makeLayoutPropertySetters() { <% for (const layer of locals.layers) { -%> <% for (const property of layer.layoutProperties) { -%> - result["<%- property.name %>"] = &setProperty<<%- camelize(layer.type) %>Layer, <%- propertyValueType(property) %>, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %><%- property.name === 'icon-image' || property.name === 'text-field' ? ', true' : '' %>>; + result["<%- property.name %>"] = &setProperty<<%- camelize(layer.type) %>Layer, <%- propertyValueType(property) %>, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>, <%- property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven' %>, <%- property.name === 'icon-image' || property.name === 'text-field' %>>; <% } -%> <% } -%> @@ -33,7 +33,7 @@ inline auto makePaintPropertySetters() { <% for (const layer of locals.layers) { -%> <% for (const property of layer.paintProperties) { -%> - result["<%- property.name %>"] = &setProperty<<%- camelize(layer.type) %>Layer, <%- propertyValueType(property) %>, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>>; + result["<%- property.name %>"] = &setProperty<<%- camelize(layer.type) %>Layer, <%- propertyValueType(property) %>, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>, <%- property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven' %>, <%- property.name === 'icon-image' || property.name === 'text-field' %>>; result["<%- property.name %>-transition"] = &setTransition<<%- camelize(layer.type) %>Layer, &<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>Transition>; <% } -%> diff --git a/src/mbgl/style/conversion/property_setter.hpp b/src/mbgl/style/conversion/property_setter.hpp index cdb585aa29..3c5c65f96a 100644 --- a/src/mbgl/style/conversion/property_setter.hpp +++ b/src/mbgl/style/conversion/property_setter.hpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -17,7 +16,7 @@ namespace conversion { using PropertySetter = optional (*) (Layer&, const Convertible&); -template +template optional setProperty(Layer& layer, const Convertible& value) { auto* typedLayer = layer.as(); if (!typedLayer) { @@ -25,7 +24,7 @@ optional setProperty(Layer& layer, const Convertible& value) { } Error error; - optional typedValue = convert(value, error, convertTokens); + optional typedValue = convert(value, error, allowDataExpressions, convertTokens); if (!typedValue) { return error; } diff --git a/src/mbgl/style/conversion/stringify.hpp b/src/mbgl/style/conversion/stringify.hpp index 77a39c51f9..3d188b6390 100644 --- a/src/mbgl/style/conversion/stringify.hpp +++ b/src/mbgl/style/conversion/stringify.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -155,19 +154,6 @@ void stringify(Writer& writer, const PropertyValue& value) { } } -template -void stringify(Writer& writer, const DataDrivenPropertyValue& v) { - v.evaluate([&] (const auto& v_) { stringify(writer, v_); }); -} - -template -void stringify(Writer& writer, const DataDrivenPropertyValue& value) { - if (!value.isUndefined()) { - writer.Key(Property::key); - stringify(writer, value); - } -} - } // namespace conversion } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index 6dd744df1f..d435ce89e1 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -96,15 +96,15 @@ void CircleLayer::setMaxZoom(float maxZoom) { // Paint properties -DataDrivenPropertyValue CircleLayer::getDefaultCircleRadius() { +PropertyValue CircleLayer::getDefaultCircleRadius() { return { 5 }; } -DataDrivenPropertyValue CircleLayer::getCircleRadius() const { +PropertyValue CircleLayer::getCircleRadius() const { return impl().paint.template get().value; } -void CircleLayer::setCircleRadius(DataDrivenPropertyValue value) { +void CircleLayer::setCircleRadius(PropertyValue value) { if (value == getCircleRadius()) return; auto impl_ = mutableImpl(); @@ -123,15 +123,15 @@ TransitionOptions CircleLayer::getCircleRadiusTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue CircleLayer::getDefaultCircleColor() { +PropertyValue CircleLayer::getDefaultCircleColor() { return { Color::black() }; } -DataDrivenPropertyValue CircleLayer::getCircleColor() const { +PropertyValue CircleLayer::getCircleColor() const { return impl().paint.template get().value; } -void CircleLayer::setCircleColor(DataDrivenPropertyValue value) { +void CircleLayer::setCircleColor(PropertyValue value) { if (value == getCircleColor()) return; auto impl_ = mutableImpl(); @@ -150,15 +150,15 @@ TransitionOptions CircleLayer::getCircleColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue CircleLayer::getDefaultCircleBlur() { +PropertyValue CircleLayer::getDefaultCircleBlur() { return { 0 }; } -DataDrivenPropertyValue CircleLayer::getCircleBlur() const { +PropertyValue CircleLayer::getCircleBlur() const { return impl().paint.template get().value; } -void CircleLayer::setCircleBlur(DataDrivenPropertyValue value) { +void CircleLayer::setCircleBlur(PropertyValue value) { if (value == getCircleBlur()) return; auto impl_ = mutableImpl(); @@ -177,15 +177,15 @@ TransitionOptions CircleLayer::getCircleBlurTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue CircleLayer::getDefaultCircleOpacity() { +PropertyValue CircleLayer::getDefaultCircleOpacity() { return { 1 }; } -DataDrivenPropertyValue CircleLayer::getCircleOpacity() const { +PropertyValue CircleLayer::getCircleOpacity() const { return impl().paint.template get().value; } -void CircleLayer::setCircleOpacity(DataDrivenPropertyValue value) { +void CircleLayer::setCircleOpacity(PropertyValue value) { if (value == getCircleOpacity()) return; auto impl_ = mutableImpl(); @@ -312,15 +312,15 @@ TransitionOptions CircleLayer::getCirclePitchAlignmentTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue CircleLayer::getDefaultCircleStrokeWidth() { +PropertyValue CircleLayer::getDefaultCircleStrokeWidth() { return { 0 }; } -DataDrivenPropertyValue CircleLayer::getCircleStrokeWidth() const { +PropertyValue CircleLayer::getCircleStrokeWidth() const { return impl().paint.template get().value; } -void CircleLayer::setCircleStrokeWidth(DataDrivenPropertyValue value) { +void CircleLayer::setCircleStrokeWidth(PropertyValue value) { if (value == getCircleStrokeWidth()) return; auto impl_ = mutableImpl(); @@ -339,15 +339,15 @@ TransitionOptions CircleLayer::getCircleStrokeWidthTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue CircleLayer::getDefaultCircleStrokeColor() { +PropertyValue CircleLayer::getDefaultCircleStrokeColor() { return { Color::black() }; } -DataDrivenPropertyValue CircleLayer::getCircleStrokeColor() const { +PropertyValue CircleLayer::getCircleStrokeColor() const { return impl().paint.template get().value; } -void CircleLayer::setCircleStrokeColor(DataDrivenPropertyValue value) { +void CircleLayer::setCircleStrokeColor(PropertyValue value) { if (value == getCircleStrokeColor()) return; auto impl_ = mutableImpl(); @@ -366,15 +366,15 @@ TransitionOptions CircleLayer::getCircleStrokeColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue CircleLayer::getDefaultCircleStrokeOpacity() { +PropertyValue CircleLayer::getDefaultCircleStrokeOpacity() { return { 1 }; } -DataDrivenPropertyValue CircleLayer::getCircleStrokeOpacity() const { +PropertyValue CircleLayer::getCircleStrokeOpacity() const { return impl().paint.template get().value; } -void CircleLayer::setCircleStrokeOpacity(DataDrivenPropertyValue value) { +void CircleLayer::setCircleStrokeOpacity(PropertyValue value) { if (value == getCircleStrokeOpacity()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index c5b4ef0ef3..829a24f354 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -123,15 +123,15 @@ TransitionOptions FillExtrusionLayer::getFillExtrusionOpacityTransition() const return impl().paint.template get().options; } -DataDrivenPropertyValue FillExtrusionLayer::getDefaultFillExtrusionColor() { +PropertyValue FillExtrusionLayer::getDefaultFillExtrusionColor() { return { Color::black() }; } -DataDrivenPropertyValue FillExtrusionLayer::getFillExtrusionColor() const { +PropertyValue FillExtrusionLayer::getFillExtrusionColor() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionColor(DataDrivenPropertyValue value) { +void FillExtrusionLayer::setFillExtrusionColor(PropertyValue value) { if (value == getFillExtrusionColor()) return; auto impl_ = mutableImpl(); @@ -231,15 +231,15 @@ TransitionOptions FillExtrusionLayer::getFillExtrusionPatternTransition() const return impl().paint.template get().options; } -DataDrivenPropertyValue FillExtrusionLayer::getDefaultFillExtrusionHeight() { +PropertyValue FillExtrusionLayer::getDefaultFillExtrusionHeight() { return { 0 }; } -DataDrivenPropertyValue FillExtrusionLayer::getFillExtrusionHeight() const { +PropertyValue FillExtrusionLayer::getFillExtrusionHeight() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionHeight(DataDrivenPropertyValue value) { +void FillExtrusionLayer::setFillExtrusionHeight(PropertyValue value) { if (value == getFillExtrusionHeight()) return; auto impl_ = mutableImpl(); @@ -258,15 +258,15 @@ TransitionOptions FillExtrusionLayer::getFillExtrusionHeightTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue FillExtrusionLayer::getDefaultFillExtrusionBase() { +PropertyValue FillExtrusionLayer::getDefaultFillExtrusionBase() { return { 0 }; } -DataDrivenPropertyValue FillExtrusionLayer::getFillExtrusionBase() const { +PropertyValue FillExtrusionLayer::getFillExtrusionBase() const { return impl().paint.template get().value; } -void FillExtrusionLayer::setFillExtrusionBase(DataDrivenPropertyValue value) { +void FillExtrusionLayer::setFillExtrusionBase(PropertyValue value) { if (value == getFillExtrusionBase()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index 99a2a51ed0..8eebd54e3c 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -123,15 +123,15 @@ TransitionOptions FillLayer::getFillAntialiasTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue FillLayer::getDefaultFillOpacity() { +PropertyValue FillLayer::getDefaultFillOpacity() { return { 1 }; } -DataDrivenPropertyValue FillLayer::getFillOpacity() const { +PropertyValue FillLayer::getFillOpacity() const { return impl().paint.template get().value; } -void FillLayer::setFillOpacity(DataDrivenPropertyValue value) { +void FillLayer::setFillOpacity(PropertyValue value) { if (value == getFillOpacity()) return; auto impl_ = mutableImpl(); @@ -150,15 +150,15 @@ TransitionOptions FillLayer::getFillOpacityTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue FillLayer::getDefaultFillColor() { +PropertyValue FillLayer::getDefaultFillColor() { return { Color::black() }; } -DataDrivenPropertyValue FillLayer::getFillColor() const { +PropertyValue FillLayer::getFillColor() const { return impl().paint.template get().value; } -void FillLayer::setFillColor(DataDrivenPropertyValue value) { +void FillLayer::setFillColor(PropertyValue value) { if (value == getFillColor()) return; auto impl_ = mutableImpl(); @@ -177,15 +177,15 @@ TransitionOptions FillLayer::getFillColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue FillLayer::getDefaultFillOutlineColor() { +PropertyValue FillLayer::getDefaultFillOutlineColor() { return { {} }; } -DataDrivenPropertyValue FillLayer::getFillOutlineColor() const { +PropertyValue FillLayer::getFillOutlineColor() const { return impl().paint.template get().value; } -void FillLayer::setFillOutlineColor(DataDrivenPropertyValue value) { +void FillLayer::setFillOutlineColor(PropertyValue value) { if (value == getFillOutlineColor()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index c2a1545a00..21016ee509 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -100,15 +100,15 @@ void HeatmapLayer::setMaxZoom(float maxZoom) { // Paint properties -DataDrivenPropertyValue HeatmapLayer::getDefaultHeatmapRadius() { +PropertyValue HeatmapLayer::getDefaultHeatmapRadius() { return { 30 }; } -DataDrivenPropertyValue HeatmapLayer::getHeatmapRadius() const { +PropertyValue HeatmapLayer::getHeatmapRadius() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapRadius(DataDrivenPropertyValue value) { +void HeatmapLayer::setHeatmapRadius(PropertyValue value) { if (value == getHeatmapRadius()) return; auto impl_ = mutableImpl(); @@ -127,15 +127,15 @@ TransitionOptions HeatmapLayer::getHeatmapRadiusTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue HeatmapLayer::getDefaultHeatmapWeight() { +PropertyValue HeatmapLayer::getDefaultHeatmapWeight() { return { 1 }; } -DataDrivenPropertyValue HeatmapLayer::getHeatmapWeight() const { +PropertyValue HeatmapLayer::getHeatmapWeight() const { return impl().paint.template get().value; } -void HeatmapLayer::setHeatmapWeight(DataDrivenPropertyValue value) { +void HeatmapLayer::setHeatmapWeight(PropertyValue value) { if (value == getHeatmapWeight()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 56eac34c00..0cda849c0f 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -110,15 +110,15 @@ void LineLayer::setLineCap(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue LineLayer::getDefaultLineJoin() { +PropertyValue LineLayer::getDefaultLineJoin() { return LineJoin::defaultValue(); } -DataDrivenPropertyValue LineLayer::getLineJoin() const { +PropertyValue LineLayer::getLineJoin() const { return impl().layout.get(); } -void LineLayer::setLineJoin(DataDrivenPropertyValue value) { +void LineLayer::setLineJoin(PropertyValue value) { if (value == getLineJoin()) return; auto impl_ = mutableImpl(); @@ -161,15 +161,15 @@ void LineLayer::setLineRoundLimit(PropertyValue value) { // Paint properties -DataDrivenPropertyValue LineLayer::getDefaultLineOpacity() { +PropertyValue LineLayer::getDefaultLineOpacity() { return { 1 }; } -DataDrivenPropertyValue LineLayer::getLineOpacity() const { +PropertyValue LineLayer::getLineOpacity() const { return impl().paint.template get().value; } -void LineLayer::setLineOpacity(DataDrivenPropertyValue value) { +void LineLayer::setLineOpacity(PropertyValue value) { if (value == getLineOpacity()) return; auto impl_ = mutableImpl(); @@ -188,15 +188,15 @@ TransitionOptions LineLayer::getLineOpacityTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue LineLayer::getDefaultLineColor() { +PropertyValue LineLayer::getDefaultLineColor() { return { Color::black() }; } -DataDrivenPropertyValue LineLayer::getLineColor() const { +PropertyValue LineLayer::getLineColor() const { return impl().paint.template get().value; } -void LineLayer::setLineColor(DataDrivenPropertyValue value) { +void LineLayer::setLineColor(PropertyValue value) { if (value == getLineColor()) return; auto impl_ = mutableImpl(); @@ -269,15 +269,15 @@ TransitionOptions LineLayer::getLineTranslateAnchorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue LineLayer::getDefaultLineWidth() { +PropertyValue LineLayer::getDefaultLineWidth() { return { 1 }; } -DataDrivenPropertyValue LineLayer::getLineWidth() const { +PropertyValue LineLayer::getLineWidth() const { return impl().paint.template get().value; } -void LineLayer::setLineWidth(DataDrivenPropertyValue value) { +void LineLayer::setLineWidth(PropertyValue value) { if (value == getLineWidth()) return; auto impl_ = mutableImpl(); @@ -296,15 +296,15 @@ TransitionOptions LineLayer::getLineWidthTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue LineLayer::getDefaultLineGapWidth() { +PropertyValue LineLayer::getDefaultLineGapWidth() { return { 0 }; } -DataDrivenPropertyValue LineLayer::getLineGapWidth() const { +PropertyValue LineLayer::getLineGapWidth() const { return impl().paint.template get().value; } -void LineLayer::setLineGapWidth(DataDrivenPropertyValue value) { +void LineLayer::setLineGapWidth(PropertyValue value) { if (value == getLineGapWidth()) return; auto impl_ = mutableImpl(); @@ -323,15 +323,15 @@ TransitionOptions LineLayer::getLineGapWidthTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue LineLayer::getDefaultLineOffset() { +PropertyValue LineLayer::getDefaultLineOffset() { return { 0 }; } -DataDrivenPropertyValue LineLayer::getLineOffset() const { +PropertyValue LineLayer::getLineOffset() const { return impl().paint.template get().value; } -void LineLayer::setLineOffset(DataDrivenPropertyValue value) { +void LineLayer::setLineOffset(PropertyValue value) { if (value == getLineOffset()) return; auto impl_ = mutableImpl(); @@ -350,15 +350,15 @@ TransitionOptions LineLayer::getLineOffsetTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue LineLayer::getDefaultLineBlur() { +PropertyValue LineLayer::getDefaultLineBlur() { return { 0 }; } -DataDrivenPropertyValue LineLayer::getLineBlur() const { +PropertyValue LineLayer::getLineBlur() const { return impl().paint.template get().value; } -void LineLayer::setLineBlur(DataDrivenPropertyValue value) { +void LineLayer::setLineBlur(PropertyValue value) { if (value == getLineBlur()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index c940f3b00a..c416c6a6c5 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -206,15 +206,15 @@ void SymbolLayer::setIconRotationAlignment(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultIconSize() { +PropertyValue SymbolLayer::getDefaultIconSize() { return IconSize::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getIconSize() const { +PropertyValue SymbolLayer::getIconSize() const { return impl().layout.get(); } -void SymbolLayer::setIconSize(DataDrivenPropertyValue value) { +void SymbolLayer::setIconSize(PropertyValue value) { if (value == getIconSize()) return; auto impl_ = mutableImpl(); @@ -254,15 +254,15 @@ void SymbolLayer::setIconTextFitPadding(PropertyValue> valu baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultIconImage() { +PropertyValue SymbolLayer::getDefaultIconImage() { return IconImage::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getIconImage() const { +PropertyValue SymbolLayer::getIconImage() const { return impl().layout.get(); } -void SymbolLayer::setIconImage(DataDrivenPropertyValue value) { +void SymbolLayer::setIconImage(PropertyValue value) { if (value == getIconImage()) return; auto impl_ = mutableImpl(); @@ -270,15 +270,15 @@ void SymbolLayer::setIconImage(DataDrivenPropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultIconRotate() { +PropertyValue SymbolLayer::getDefaultIconRotate() { return IconRotate::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getIconRotate() const { +PropertyValue SymbolLayer::getIconRotate() const { return impl().layout.get(); } -void SymbolLayer::setIconRotate(DataDrivenPropertyValue value) { +void SymbolLayer::setIconRotate(PropertyValue value) { if (value == getIconRotate()) return; auto impl_ = mutableImpl(); @@ -318,15 +318,15 @@ void SymbolLayer::setIconKeepUpright(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue> SymbolLayer::getDefaultIconOffset() { +PropertyValue> SymbolLayer::getDefaultIconOffset() { return IconOffset::defaultValue(); } -DataDrivenPropertyValue> SymbolLayer::getIconOffset() const { +PropertyValue> SymbolLayer::getIconOffset() const { return impl().layout.get(); } -void SymbolLayer::setIconOffset(DataDrivenPropertyValue> value) { +void SymbolLayer::setIconOffset(PropertyValue> value) { if (value == getIconOffset()) return; auto impl_ = mutableImpl(); @@ -334,15 +334,15 @@ void SymbolLayer::setIconOffset(DataDrivenPropertyValue> va baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultIconAnchor() { +PropertyValue SymbolLayer::getDefaultIconAnchor() { return IconAnchor::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getIconAnchor() const { +PropertyValue SymbolLayer::getIconAnchor() const { return impl().layout.get(); } -void SymbolLayer::setIconAnchor(DataDrivenPropertyValue value) { +void SymbolLayer::setIconAnchor(PropertyValue value) { if (value == getIconAnchor()) return; auto impl_ = mutableImpl(); @@ -398,15 +398,15 @@ void SymbolLayer::setTextRotationAlignment(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextField() { +PropertyValue SymbolLayer::getDefaultTextField() { return TextField::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextField() const { +PropertyValue SymbolLayer::getTextField() const { return impl().layout.get(); } -void SymbolLayer::setTextField(DataDrivenPropertyValue value) { +void SymbolLayer::setTextField(PropertyValue value) { if (value == getTextField()) return; auto impl_ = mutableImpl(); @@ -414,15 +414,15 @@ void SymbolLayer::setTextField(DataDrivenPropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue> SymbolLayer::getDefaultTextFont() { +PropertyValue> SymbolLayer::getDefaultTextFont() { return TextFont::defaultValue(); } -DataDrivenPropertyValue> SymbolLayer::getTextFont() const { +PropertyValue> SymbolLayer::getTextFont() const { return impl().layout.get(); } -void SymbolLayer::setTextFont(DataDrivenPropertyValue> value) { +void SymbolLayer::setTextFont(PropertyValue> value) { if (value == getTextFont()) return; auto impl_ = mutableImpl(); @@ -430,15 +430,15 @@ void SymbolLayer::setTextFont(DataDrivenPropertyValue> baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextSize() { +PropertyValue SymbolLayer::getDefaultTextSize() { return TextSize::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextSize() const { +PropertyValue SymbolLayer::getTextSize() const { return impl().layout.get(); } -void SymbolLayer::setTextSize(DataDrivenPropertyValue value) { +void SymbolLayer::setTextSize(PropertyValue value) { if (value == getTextSize()) return; auto impl_ = mutableImpl(); @@ -446,15 +446,15 @@ void SymbolLayer::setTextSize(DataDrivenPropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextMaxWidth() { +PropertyValue SymbolLayer::getDefaultTextMaxWidth() { return TextMaxWidth::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextMaxWidth() const { +PropertyValue SymbolLayer::getTextMaxWidth() const { return impl().layout.get(); } -void SymbolLayer::setTextMaxWidth(DataDrivenPropertyValue value) { +void SymbolLayer::setTextMaxWidth(PropertyValue value) { if (value == getTextMaxWidth()) return; auto impl_ = mutableImpl(); @@ -478,15 +478,15 @@ void SymbolLayer::setTextLineHeight(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextLetterSpacing() { +PropertyValue SymbolLayer::getDefaultTextLetterSpacing() { return TextLetterSpacing::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextLetterSpacing() const { +PropertyValue SymbolLayer::getTextLetterSpacing() const { return impl().layout.get(); } -void SymbolLayer::setTextLetterSpacing(DataDrivenPropertyValue value) { +void SymbolLayer::setTextLetterSpacing(PropertyValue value) { if (value == getTextLetterSpacing()) return; auto impl_ = mutableImpl(); @@ -494,15 +494,15 @@ void SymbolLayer::setTextLetterSpacing(DataDrivenPropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextJustify() { +PropertyValue SymbolLayer::getDefaultTextJustify() { return TextJustify::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextJustify() const { +PropertyValue SymbolLayer::getTextJustify() const { return impl().layout.get(); } -void SymbolLayer::setTextJustify(DataDrivenPropertyValue value) { +void SymbolLayer::setTextJustify(PropertyValue value) { if (value == getTextJustify()) return; auto impl_ = mutableImpl(); @@ -510,15 +510,15 @@ void SymbolLayer::setTextJustify(DataDrivenPropertyValue value) baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextAnchor() { +PropertyValue SymbolLayer::getDefaultTextAnchor() { return TextAnchor::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextAnchor() const { +PropertyValue SymbolLayer::getTextAnchor() const { return impl().layout.get(); } -void SymbolLayer::setTextAnchor(DataDrivenPropertyValue value) { +void SymbolLayer::setTextAnchor(PropertyValue value) { if (value == getTextAnchor()) return; auto impl_ = mutableImpl(); @@ -542,15 +542,15 @@ void SymbolLayer::setTextMaxAngle(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextRotate() { +PropertyValue SymbolLayer::getDefaultTextRotate() { return TextRotate::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextRotate() const { +PropertyValue SymbolLayer::getTextRotate() const { return impl().layout.get(); } -void SymbolLayer::setTextRotate(DataDrivenPropertyValue value) { +void SymbolLayer::setTextRotate(PropertyValue value) { if (value == getTextRotate()) return; auto impl_ = mutableImpl(); @@ -590,15 +590,15 @@ void SymbolLayer::setTextKeepUpright(PropertyValue value) { baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue SymbolLayer::getDefaultTextTransform() { +PropertyValue SymbolLayer::getDefaultTextTransform() { return TextTransform::defaultValue(); } -DataDrivenPropertyValue SymbolLayer::getTextTransform() const { +PropertyValue SymbolLayer::getTextTransform() const { return impl().layout.get(); } -void SymbolLayer::setTextTransform(DataDrivenPropertyValue value) { +void SymbolLayer::setTextTransform(PropertyValue value) { if (value == getTextTransform()) return; auto impl_ = mutableImpl(); @@ -606,15 +606,15 @@ void SymbolLayer::setTextTransform(DataDrivenPropertyValue va baseImpl = std::move(impl_); observer->onLayerChanged(*this); } -DataDrivenPropertyValue> SymbolLayer::getDefaultTextOffset() { +PropertyValue> SymbolLayer::getDefaultTextOffset() { return TextOffset::defaultValue(); } -DataDrivenPropertyValue> SymbolLayer::getTextOffset() const { +PropertyValue> SymbolLayer::getTextOffset() const { return impl().layout.get(); } -void SymbolLayer::setTextOffset(DataDrivenPropertyValue> value) { +void SymbolLayer::setTextOffset(PropertyValue> value) { if (value == getTextOffset()) return; auto impl_ = mutableImpl(); @@ -673,15 +673,15 @@ void SymbolLayer::setTextOptional(PropertyValue value) { // Paint properties -DataDrivenPropertyValue SymbolLayer::getDefaultIconOpacity() { +PropertyValue SymbolLayer::getDefaultIconOpacity() { return { 1 }; } -DataDrivenPropertyValue SymbolLayer::getIconOpacity() const { +PropertyValue SymbolLayer::getIconOpacity() const { return impl().paint.template get().value; } -void SymbolLayer::setIconOpacity(DataDrivenPropertyValue value) { +void SymbolLayer::setIconOpacity(PropertyValue value) { if (value == getIconOpacity()) return; auto impl_ = mutableImpl(); @@ -700,15 +700,15 @@ TransitionOptions SymbolLayer::getIconOpacityTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultIconColor() { +PropertyValue SymbolLayer::getDefaultIconColor() { return { Color::black() }; } -DataDrivenPropertyValue SymbolLayer::getIconColor() const { +PropertyValue SymbolLayer::getIconColor() const { return impl().paint.template get().value; } -void SymbolLayer::setIconColor(DataDrivenPropertyValue value) { +void SymbolLayer::setIconColor(PropertyValue value) { if (value == getIconColor()) return; auto impl_ = mutableImpl(); @@ -727,15 +727,15 @@ TransitionOptions SymbolLayer::getIconColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultIconHaloColor() { +PropertyValue SymbolLayer::getDefaultIconHaloColor() { return { {} }; } -DataDrivenPropertyValue SymbolLayer::getIconHaloColor() const { +PropertyValue SymbolLayer::getIconHaloColor() const { return impl().paint.template get().value; } -void SymbolLayer::setIconHaloColor(DataDrivenPropertyValue value) { +void SymbolLayer::setIconHaloColor(PropertyValue value) { if (value == getIconHaloColor()) return; auto impl_ = mutableImpl(); @@ -754,15 +754,15 @@ TransitionOptions SymbolLayer::getIconHaloColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultIconHaloWidth() { +PropertyValue SymbolLayer::getDefaultIconHaloWidth() { return { 0 }; } -DataDrivenPropertyValue SymbolLayer::getIconHaloWidth() const { +PropertyValue SymbolLayer::getIconHaloWidth() const { return impl().paint.template get().value; } -void SymbolLayer::setIconHaloWidth(DataDrivenPropertyValue value) { +void SymbolLayer::setIconHaloWidth(PropertyValue value) { if (value == getIconHaloWidth()) return; auto impl_ = mutableImpl(); @@ -781,15 +781,15 @@ TransitionOptions SymbolLayer::getIconHaloWidthTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultIconHaloBlur() { +PropertyValue SymbolLayer::getDefaultIconHaloBlur() { return { 0 }; } -DataDrivenPropertyValue SymbolLayer::getIconHaloBlur() const { +PropertyValue SymbolLayer::getIconHaloBlur() const { return impl().paint.template get().value; } -void SymbolLayer::setIconHaloBlur(DataDrivenPropertyValue value) { +void SymbolLayer::setIconHaloBlur(PropertyValue value) { if (value == getIconHaloBlur()) return; auto impl_ = mutableImpl(); @@ -862,15 +862,15 @@ TransitionOptions SymbolLayer::getIconTranslateAnchorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultTextOpacity() { +PropertyValue SymbolLayer::getDefaultTextOpacity() { return { 1 }; } -DataDrivenPropertyValue SymbolLayer::getTextOpacity() const { +PropertyValue SymbolLayer::getTextOpacity() const { return impl().paint.template get().value; } -void SymbolLayer::setTextOpacity(DataDrivenPropertyValue value) { +void SymbolLayer::setTextOpacity(PropertyValue value) { if (value == getTextOpacity()) return; auto impl_ = mutableImpl(); @@ -889,15 +889,15 @@ TransitionOptions SymbolLayer::getTextOpacityTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultTextColor() { +PropertyValue SymbolLayer::getDefaultTextColor() { return { Color::black() }; } -DataDrivenPropertyValue SymbolLayer::getTextColor() const { +PropertyValue SymbolLayer::getTextColor() const { return impl().paint.template get().value; } -void SymbolLayer::setTextColor(DataDrivenPropertyValue value) { +void SymbolLayer::setTextColor(PropertyValue value) { if (value == getTextColor()) return; auto impl_ = mutableImpl(); @@ -916,15 +916,15 @@ TransitionOptions SymbolLayer::getTextColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultTextHaloColor() { +PropertyValue SymbolLayer::getDefaultTextHaloColor() { return { {} }; } -DataDrivenPropertyValue SymbolLayer::getTextHaloColor() const { +PropertyValue SymbolLayer::getTextHaloColor() const { return impl().paint.template get().value; } -void SymbolLayer::setTextHaloColor(DataDrivenPropertyValue value) { +void SymbolLayer::setTextHaloColor(PropertyValue value) { if (value == getTextHaloColor()) return; auto impl_ = mutableImpl(); @@ -943,15 +943,15 @@ TransitionOptions SymbolLayer::getTextHaloColorTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultTextHaloWidth() { +PropertyValue SymbolLayer::getDefaultTextHaloWidth() { return { 0 }; } -DataDrivenPropertyValue SymbolLayer::getTextHaloWidth() const { +PropertyValue SymbolLayer::getTextHaloWidth() const { return impl().paint.template get().value; } -void SymbolLayer::setTextHaloWidth(DataDrivenPropertyValue value) { +void SymbolLayer::setTextHaloWidth(PropertyValue value) { if (value == getTextHaloWidth()) return; auto impl_ = mutableImpl(); @@ -970,15 +970,15 @@ TransitionOptions SymbolLayer::getTextHaloWidthTransition() const { return impl().paint.template get().options; } -DataDrivenPropertyValue SymbolLayer::getDefaultTextHaloBlur() { +PropertyValue SymbolLayer::getDefaultTextHaloBlur() { return { 0 }; } -DataDrivenPropertyValue SymbolLayer::getTextHaloBlur() const { +PropertyValue SymbolLayer::getTextHaloBlur() const { return impl().paint.template get().value; } -void SymbolLayer::setTextHaloBlur(DataDrivenPropertyValue value) { +void SymbolLayer::setTextHaloBlur(PropertyValue value) { if (value == getTextHaloBlur()) return; auto impl_ = mutableImpl(); diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp index 8c59295ad2..0fcad30cc4 100644 --- a/src/mbgl/style/layout_property.hpp +++ b/src/mbgl/style/layout_property.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include @@ -23,7 +22,7 @@ template class DataDrivenLayoutProperty { public: using TransitionableType = std::nullptr_t; - using UnevaluatedType = DataDrivenPropertyValue; + using UnevaluatedType = PropertyValue; using EvaluatorType = DataDrivenPropertyEvaluator; using PossiblyEvaluatedType = PossiblyEvaluatedPropertyValue; using Type = T; diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp index d51a6760c5..3d9d7710dc 100644 --- a/src/mbgl/style/paint_property.hpp +++ b/src/mbgl/style/paint_property.hpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -27,8 +26,8 @@ public: template class DataDrivenPaintProperty { public: - using TransitionableType = Transitionable>; - using UnevaluatedType = Transitioning>; + using TransitionableType = Transitionable>; + using UnevaluatedType = Transitioning>; using EvaluatorType = DataDrivenPropertyEvaluator; using PossiblyEvaluatedType = PossiblyEvaluatedPropertyValue; using Type = T; @@ -67,7 +66,7 @@ public: using PossiblyEvaluatedType = Color; using Type = Color; static constexpr bool IsDataDriven = false; - + static Color defaultValue() { return {}; } }; diff --git a/test/style/conversion/function.test.cpp b/test/style/conversion/function.test.cpp index 4612147f76..e63ad722cf 100644 --- a/test/style/conversion/function.test.cpp +++ b/test/style/conversion/function.test.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include using namespace mbgl; @@ -14,7 +13,7 @@ TEST(StyleConversion, Function) { Error error; auto parseFunction = [&](const std::string& json) { - return convertJSON>(json, error); + return convertJSON>(json, error, false, false); }; auto fn1 = parseFunction(R"({"stops":[]})"); @@ -57,12 +56,12 @@ TEST(StyleConversion, CompositeFunctionExpression) { Error error; auto parseFunction = [&](const std::string& json) { - return convertJSON>(json, error, false); + return convertJSON>(json, error, true, false); }; auto fn1 = parseFunction(R"(["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10])"); ASSERT_TRUE(fn1); - + auto fn2 = parseFunction(R"(["coalesce", ["interpolate", ["linear"], ["zoom"], 0, ["number", ["get", "x"]], 10, 10], 0])"); ASSERT_TRUE(fn2); diff --git a/test/style/conversion/property_value.test.cpp b/test/style/conversion/property_value.test.cpp index dcb08bcec7..e8a7d844cd 100644 --- a/test/style/conversion/property_value.test.cpp +++ b/test/style/conversion/property_value.test.cpp @@ -14,7 +14,7 @@ TEST(StyleConversion, PropertyValue) { JSDocument doc; doc.Parse<0>(R"(["literal", [1, 2]])"); auto expected = std::array{{1, 2}}; - auto result = convert>>(doc, error); + auto result = convert>>(doc, error, false, false); ASSERT_TRUE(result); ASSERT_TRUE(result->isConstant()); ASSERT_EQ(result->asConstant(), expected); diff --git a/test/style/properties.test.cpp b/test/style/properties.test.cpp index ef064ccba2..f3af1a92b2 100644 --- a/test/style/properties.test.cpp +++ b/test/style/properties.test.cpp @@ -27,7 +27,7 @@ float evaluate(Transitioning>& property, Duration delta = D return property.evaluate(evaluator, parameters.now); } -PossiblyEvaluatedPropertyValue evaluate(Transitioning>& property, Duration delta = Duration::zero()) { +PossiblyEvaluatedPropertyValue evaluateDataExpression(Transitioning>& property, Duration delta = Duration::zero()) { ZoomHistory zoomHistory; zoomHistory.update(0, TimePoint::min() + delta); @@ -36,12 +36,12 @@ PossiblyEvaluatedPropertyValue evaluate(Transitioning evaluator { parameters, 0.0f }; - + return property.evaluate(evaluator, parameters.now); } @@ -114,10 +114,10 @@ TEST(TransitioningDataDrivenPropertyValue, Evaluate) { TransitionOptions transition; transition.delay = { 1000ms }; transition.duration = { 1000ms }; - - Transitioning> t0 { - DataDrivenPropertyValue(0.0f), - Transitioning>(), + + Transitioning> t0 { + PropertyValue(0.0f), + Transitioning>(), TransitionOptions(), TimePoint::min() }; @@ -125,14 +125,14 @@ TEST(TransitioningDataDrivenPropertyValue, Evaluate) { using namespace mbgl::style::expression::dsl; PropertyExpression expression(number(get("property_name"))); - Transitioning> t1 { - DataDrivenPropertyValue(expression), + Transitioning> t1 { + PropertyValue(expression), t0, transition, TimePoint::min() }; - - ASSERT_TRUE(evaluate(t0, 0ms).isConstant()); - ASSERT_FALSE(evaluate(t1, 0ms).isConstant()) << + + ASSERT_TRUE(evaluateDataExpression(t0, 0ms).isConstant()); + ASSERT_FALSE(evaluateDataExpression(t1, 0ms).isConstant()) << "A paint property transition to a data-driven evaluates immediately to the final value (see https://github.com/mapbox/mapbox-gl-native/issues/8237)."; } -- cgit v1.2.1