diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-02-15 11:54:51 -0500 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-02-15 11:54:51 -0500 |
commit | 903e7989ec3438a605bafbf5938de38cdb868e4a (patch) | |
tree | a2f8ba01fd8bf41503396605b993f9e38b77e131 /platform/darwin/src/MGLStyleValue_Private.h | |
parent | c83dc310aa656132638a66e65ba8aa274b5e969f (diff) | |
parent | 82de856c94bbc090ba30186011610da5e233e277 (diff) | |
download | qtlocation-mapboxgl-903e7989ec3438a605bafbf5938de38cdb868e4a.tar.gz |
Merge branch 'master' into release-boba
# Conflicts:
# platform/android/CHANGELOG.md
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
# platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
# platform/android/scripts/exclude-activity-gen.json
# platform/ios/CHANGELOG.md
# platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec
# platform/ios/Mapbox-iOS-SDK-symbols.podspec
# platform/ios/Mapbox-iOS-SDK.podspec
# platform/macos/CHANGELOG.md
Diffstat (limited to 'platform/darwin/src/MGLStyleValue_Private.h')
-rw-r--r-- | platform/darwin/src/MGLStyleValue_Private.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index ba4b413a3c..5124c29a90 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -10,6 +10,7 @@ #import "MGLConversion.h" #include <mbgl/style/conversion/property_value.hpp> #include <mbgl/style/conversion/data_driven_property_value.hpp> +#include <mbgl/style/conversion/heatmap_color_property_value.hpp> #include <mbgl/style/conversion/position.hpp> #import <mbgl/style/types.hpp> @@ -52,11 +53,20 @@ public: return mbglValue.evaluate(evaluator); } + // Convert an mbgl heatmap color property value into an mgl style value + NSExpression *toExpression(const mbgl::style::HeatmapColorPropertyValue &mbglValue) { + if (mbglValue.isUndefined()) { + return nil; + } + return [NSExpression mgl_expressionWithJSONObject:MGLJSONObjectFromMBGLExpression(mbglValue.getExpression())]; + } + /** Converts an NSExpression to an mbgl property value. */ template <typename MBGLValue> - MBGLValue toPropertyValue(NSExpression *expression) { + typename std::enable_if_t<!std::is_same<MBGLValue, mbgl::style::HeatmapColorPropertyValue>::value, + MBGLValue> toPropertyValue(NSExpression *expression) { if (!expression) { return {}; } @@ -85,6 +95,30 @@ public: return *value; } + + /** + Converts an NSExpression to an mbgl property value. + */ + template <typename MBGLValue> + typename std::enable_if_t<std::is_same<MBGLValue, mbgl::style::HeatmapColorPropertyValue>::value, + MBGLValue> toPropertyValue(NSExpression *expression) { + if (!expression) { + return {}; + } + + NSArray *jsonExpression = expression.mgl_jsonExpressionObject; + + mbgl::style::conversion::Error valueError; + auto value = mbgl::style::conversion::convert<mbgl::style::HeatmapColorPropertyValue>( + mbgl::style::conversion::makeConvertible(jsonExpression), valueError); + if (!value) { + [NSException raise:NSInvalidArgumentException + format:@"Invalid property value: %@", @(valueError.message.c_str())]; + return {}; + } + + return *value; + } private: // Private utilities for converting from mgl to mbgl values |