diff options
author | Jesse Bounds <jesse@rebounds.net> | 2017-02-08 12:27:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-08 12:27:12 -0800 |
commit | 06a8ed79598beae923b795dea711834b4775f6b0 (patch) | |
tree | 65afbaaf19bee1e7ed7508d6c3b49ee88aa6fc37 /platform/darwin/src/MGLStyleValue_Private.h | |
parent | 6d69686a12f5fb3761e3318410f5626198d0b92c (diff) | |
download | qtlocation-mapboxgl-06a8ed79598beae923b795dea711834b4775f6b0.tar.gz |
Add back MGLStyleFunction and re-document MGLStyleValue (#7943)
[ios, macos] Add back MGLStyleFunction and re-document MGLStyleValue
Diffstat (limited to 'platform/darwin/src/MGLStyleValue_Private.h')
-rw-r--r-- | platform/darwin/src/MGLStyleValue_Private.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index b4354d7d16..03a8f242cf 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -60,6 +60,9 @@ public: // a deprecated MGLStyleValue method (that used to create an MGLStyleFunction) to create a function // for properties that are piecewise-constant (i.e. enum, bool, string) return toMBGLIntervalCameraFunction(cameraStyleFunction); + } else if ([value isMemberOfClass:[MGLStyleFunction class]]) { + MGLStyleFunction<ObjCType> *styleFunction = (MGLStyleFunction<ObjCType> *)value; + return toMBGLIntervalCameraFunction(styleFunction); } else if (value) { [NSException raise:@"MGLAbstractClassException" format: @"The style value %@ cannot be applied to the style. " @@ -81,6 +84,9 @@ public: if ([value isKindOfClass:[MGLStyleConstantValue class]]) { return toMBGLConstantValue((MGLStyleConstantValue<ObjCType> *)value); + } else if ([value isMemberOfClass:[MGLStyleFunction class]]) { + MGLStyleFunction<ObjCType> *styleFunction = (MGLStyleFunction<ObjCType> *)value; + return toMBGLExponentialCameraFunction(styleFunction); } else if ([value isKindOfClass:[MGLCameraStyleFunction class]]) { MGLCameraStyleFunction<ObjCType> *cameraStyleFunction = (MGLCameraStyleFunction<ObjCType> *)value; switch (cameraStyleFunction.interpolationMode) { @@ -247,6 +253,9 @@ public: return {}; } return {}; + } else if ([value isMemberOfClass:[MGLStyleFunction class]]) { + MGLStyleFunction<ObjCType> *styleFunction = (MGLStyleFunction<ObjCType> *)value; + return toMBGLExponentialCameraFunction(styleFunction); } else if (value) { [NSException raise:@"MGLAbstractClassException" format: @"The style value %@ cannot be applied to the style. " @@ -308,9 +317,9 @@ private: // Private utilities for converting from mgl to mbgl values return mbglValue; } - mbgl::style::CameraFunction<MBGLType> toMBGLExponentialCameraFunction(MGLCameraStyleFunction<ObjCType> *cameraStyleFunction) { + mbgl::style::CameraFunction<MBGLType> toMBGLExponentialCameraFunction(MGLStyleFunction<ObjCType> *styleFunction) { __block std::map<float, MBGLType> stops = {}; - [cameraStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) { + [styleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) { NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); auto mbglStopValue = toPropertyValue(stopValue); NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); @@ -318,15 +327,15 @@ private: // Private utilities for converting from mgl to mbgl values }]; // Camera function with Exponential stops - mbgl::style::ExponentialStops<MBGLType> exponentialStops = {stops, (float)cameraStyleFunction.interpolationBase}; + mbgl::style::ExponentialStops<MBGLType> exponentialStops = {stops, (float)styleFunction.interpolationBase}; mbgl::style::CameraFunction<MBGLType> cameraFunction = {exponentialStops}; return cameraFunction; } - mbgl::style::CameraFunction<MBGLType> toMBGLIntervalCameraFunction(MGLCameraStyleFunction<ObjCType> *cameraStyleFunction) { + mbgl::style::CameraFunction<MBGLType> toMBGLIntervalCameraFunction(MGLStyleFunction<ObjCType> *styleFunction) { __block std::map<float, MBGLType> stops = {}; - [cameraStyleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) { + [styleFunction.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue<ObjCType> * _Nonnull stopValue, BOOL * _Nonnull stop) { NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); auto mbglStopValue = toPropertyValue(stopValue); NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); |