summaryrefslogtreecommitdiff
path: root/include/mbgl/style/conversion/property_value.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/style/conversion/property_value.hpp')
-rw-r--r--include/mbgl/style/conversion/property_value.hpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/include/mbgl/style/conversion/property_value.hpp b/include/mbgl/style/conversion/property_value.hpp
index e52c63d023..2256cfffb4 100644
--- a/include/mbgl/style/conversion/property_value.hpp
+++ b/include/mbgl/style/conversion/property_value.hpp
@@ -7,7 +7,6 @@
#include <mbgl/style/expression/value.hpp>
#include <mbgl/style/expression/is_constant.hpp>
#include <mbgl/style/expression/is_expression.hpp>
-#include <mbgl/style/expression/find_zoom_curve.hpp>
#include <mbgl/style/expression/parsing_context.hpp>
#include <mbgl/style/expression/literal.hpp>
@@ -22,34 +21,20 @@ struct Converter<PropertyValue<T>> {
if (isUndefined(value)) {
return PropertyValue<T>();
- } else if (isExpression(value)) {
+ }
+
+ optional<PropertyExpression<T>> expression;
+
+ if (isExpression(value)) {
ParsingContext ctx(valueTypeToExpressionType<T>());
- ParseResult expression = ctx.parseLayerPropertyExpression(value);
- if (!expression) {
+ ParseResult parsed = ctx.parseLayerPropertyExpression(value);
+ if (!parsed) {
error = { ctx.getCombinedErrors() };
return {};
}
-
- if (!isFeatureConstant(**expression)) {
- error = { "property expressions not supported" };
- return {};
- } else if (!isZoomConstant(**expression)) {
- return { CameraFunction<T>(std::move(*expression)) };
- } else {
- auto literal = dynamic_cast<Literal*>(expression->get());
- assert(literal);
- optional<T> constant = fromExpressionValue<T>(literal->getValue());
- if (!constant) {
- return {};
- }
- return PropertyValue<T>(*constant);
- }
+ expression = PropertyExpression<T>(std::move(*parsed));
} else if (isObject(value)) {
- optional<CameraFunction<T>> function = convert<CameraFunction<T>>(value, error);
- if (!function) {
- return {};
- }
- return { *function };
+ expression = convertFunctionToExpression<T>(value, error);
} else {
optional<T> constant = convert<T>(value, error);
if (!constant) {
@@ -57,6 +42,22 @@ struct Converter<PropertyValue<T>> {
}
return { *constant };
}
+
+ if (!expression) {
+ return {};
+ } else if (!(*expression).isFeatureConstant()) {
+ error = { "data expressions not supported" };
+ return {};
+ } else if (!(*expression).isZoomConstant()) {
+ return { std::move(*expression) };
+ } else {
+ optional<T> constant = fromExpressionValue<T>(
+ dynamic_cast<const Literal&>((*expression).getExpression()).getValue());
+ if (!constant) {
+ return {};
+ }
+ return PropertyValue<T>(*constant);
+ }
}
};