diff options
Diffstat (limited to 'include/mbgl/style/conversion/data_driven_property_value.hpp')
-rw-r--r-- | include/mbgl/style/conversion/data_driven_property_value.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/mbgl/style/conversion/data_driven_property_value.hpp b/include/mbgl/style/conversion/data_driven_property_value.hpp index 1e54c15a49..8880d28fb1 100644 --- a/include/mbgl/style/conversion/data_driven_property_value.hpp +++ b/include/mbgl/style/conversion/data_driven_property_value.hpp @@ -4,6 +4,13 @@ #include <mbgl/style/conversion.hpp> #include <mbgl/style/conversion/constant.hpp> #include <mbgl/style/conversion/function.hpp> +#include <mbgl/style/conversion/expression.hpp> +#include <mbgl/style/expression/is_expression.hpp> +#include <mbgl/style/expression/is_constant.hpp> +#include <mbgl/style/expression/find_zoom_curve.hpp> + +#include <unordered_set> + namespace mbgl { namespace style { @@ -11,9 +18,27 @@ namespace conversion { template <class T> struct Converter<DataDrivenPropertyValue<T>> { + optional<DataDrivenPropertyValue<T>> operator()(const Convertible& value, Error& error) const { if (isUndefined(value)) { return DataDrivenPropertyValue<T>(); + } else if (expression::isExpression(value)) { + optional<std::unique_ptr<Expression>> expression = convert<std::unique_ptr<Expression>>( + value, + error, + valueTypeToExpressionType<T>()); + + if (!expression) { + return {}; + } + + if (isFeatureConstant(**expression)) { + return DataDrivenPropertyValue<T>(CameraFunction<T>(std::move(*expression))); + } else if (isZoomConstant(**expression)) { + return DataDrivenPropertyValue<T>(SourceFunction<T>(std::move(*expression))); + } else { + return DataDrivenPropertyValue<T>(CompositeFunction<T>(std::move(*expression))); + } } else if (!isObject(value)) { optional<T> constant = convert<T>(value, error); if (!constant) { |