summaryrefslogtreecommitdiff
path: root/include/mbgl/style/conversion/data_driven_property_value.hpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-10 19:18:39 -0200
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-11-12 13:41:08 -0200
commit1adc585c61e1e42f28c7944816010446091fa161 (patch)
treeafbab98a080dcea67851e5bfb43f78d7776be423 /include/mbgl/style/conversion/data_driven_property_value.hpp
parenta2120304a881507ed60c3199925946c1df06b44c (diff)
downloadqtlocation-mapboxgl-1adc585c61e1e42f28c7944816010446091fa161.tar.gz
Bump Mapbox GL Native
mapbox-gl-native @ 92608f58858d77c17a65ae9b29758e74bb2da7d2
Diffstat (limited to 'include/mbgl/style/conversion/data_driven_property_value.hpp')
-rw-r--r--include/mbgl/style/conversion/data_driven_property_value.hpp25
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) {