summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyleValue_Private.h
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLStyleValue_Private.h')
-rw-r--r--platform/darwin/src/MGLStyleValue_Private.h47
1 files changed, 18 insertions, 29 deletions
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 <mbgl/style/conversion/color_ramp_property_value.hpp>
#include <mbgl/style/conversion/property_value.hpp>
-#include <mbgl/style/conversion/data_driven_property_value.hpp>
#include <mbgl/style/conversion/position.hpp>
#import <mbgl/style/types.hpp>
#import <mbgl/util/enum.hpp>
-
-#include <mbgl/style/data_driven_property_value.hpp>
-
#include <mbgl/util/interpolate.hpp>
#if TARGET_OS_IPHONE
@@ -39,20 +35,13 @@ id MGLJSONObjectFromMBGLExpression(const mbgl::style::expression::Expression &mb
template <typename MBGLType, typename ObjCType, typename MBGLElement = MBGLType, typename ObjCEnum = ObjCType>
class MGLStyleValueTransformer {
public:
-
+
/// Convert an mbgl property value into an mgl style value
NSExpression *toExpression(const mbgl::style::PropertyValue<MBGLType> &mbglValue) {
PropertyExpressionEvaluator evaluator;
return mbglValue.evaluate(evaluator);
}
-
- /// Convert an mbgl data driven property value into an mgl style value
- template <typename MBGLEnum = MBGLType, typename MGLEnum = ObjCEnum>
- NSExpression *toExpression(const mbgl::style::DataDrivenPropertyValue<MBGLEnum> &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 MBGLValue>
typename std::enable_if_t<!std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::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<MBGLValue>(
- 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::ColorRampPropertyValue>(
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 <typename MBGLEnum = MBGLType,
class = typename std::enable_if<std::is_enum<MBGLEnum>::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<MGLEnum>::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<float, 3> 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 <typename MBGLEnum = MBGLType,
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
typename MGLEnum = ObjCEnum,