[ios, macos] Rename base to interpolationBase (#7486)
This commit is contained in:
@@ -49,13 +49,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Creates and returns an `MGLStyleFunction` object representing a zoom level
|
||||
function with an exponential base and any number of stops.
|
||||
function with an exponential interpolation base and any number of stops.
|
||||
|
||||
@param base The exponential base of the interpolation curve.
|
||||
@param interpolationBase The exponential base of the interpolation curve.
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given base and stops.
|
||||
@return An `MGLStyleFunction` object with the given interpolation base and stops.
|
||||
*/
|
||||
+ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
+ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
|
||||
@end
|
||||
|
||||
@@ -126,38 +126,38 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Creates and returns an `MGLStyleFunction` object representing a zoom level
|
||||
function with an exponential base and any number of stops.
|
||||
function with an exponential interpolation base and any number of stops.
|
||||
|
||||
@param base The exponential base of the interpolation curve.
|
||||
@param interpolationBase The exponential base of the interpolation curve.
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given base and stops.
|
||||
@return An `MGLStyleFunction` object with the given interpolation base and stops.
|
||||
*/
|
||||
+ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
+ (instancetype)functionWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops;
|
||||
|
||||
#pragma mark Initializing a Style Function
|
||||
|
||||
/**
|
||||
Returns an `MGLStyleFunction` object representing a zoom level function with an
|
||||
exponential base and any number of stops.
|
||||
exponential interpolation base and any number of stops.
|
||||
|
||||
@param base The exponential base of the interpolation curve.
|
||||
@param interpolationBase The exponential base of the interpolation curve.
|
||||
@param stops A dictionary associating zoom levels with style values.
|
||||
@return An `MGLStyleFunction` object with the given base and stops.
|
||||
@return An `MGLStyleFunction` object with the given interpolation base and stops.
|
||||
*/
|
||||
- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)initWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary<NSNumber *, MGLStyleValue<T> *> *)stops NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
#pragma mark Accessing the Parameters of a Function
|
||||
|
||||
/**
|
||||
The exponential base of the function’s interpolation curve.
|
||||
The exponential interpolation base of the function’s interpolation curve.
|
||||
|
||||
The exponential base controls the rate at which the function’s output values
|
||||
The exponential interpolation base controls the rate at which the function’s output values
|
||||
increase. A value of 1 causes the function to increase linearly by zoom level.
|
||||
A higher exponential base causes the function’s output values to vary
|
||||
A higher exponential interpolation base causes the function’s output values to vary
|
||||
exponentially, increasing more rapidly towards the high end of the function’s
|
||||
range. The default value of this property is 1, for a linear curve.
|
||||
*/
|
||||
@property (nonatomic) CGFloat base;
|
||||
@property (nonatomic) CGFloat interpolationBase;
|
||||
|
||||
/**
|
||||
A dictionary associating zoom levels with style values.
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
return [MGLStyleConstantValue valueWithRawValue:rawValue];
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *)stops {
|
||||
return [MGLStyleFunction functionWithBase:base stops:stops];
|
||||
+ (instancetype)valueWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary *)stops {
|
||||
return [MGLStyleFunction functionWithInterpolationBase:interpolationBase stops:stops];
|
||||
}
|
||||
|
||||
+ (instancetype)valueWithStops:(NSDictionary *)stops {
|
||||
@@ -49,44 +49,44 @@
|
||||
|
||||
@implementation MGLStyleFunction
|
||||
|
||||
+ (instancetype)functionWithBase:(CGFloat)base stops:(NSDictionary *)stops {
|
||||
return [[self alloc] initWithBase:base stops:stops];
|
||||
+ (instancetype)functionWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary *)stops {
|
||||
return [[self alloc] initWithInterpolationBase:interpolationBase stops:stops];
|
||||
}
|
||||
|
||||
+ (instancetype)functionWithStops:(NSDictionary *)stops {
|
||||
return [[self alloc] initWithBase:1 stops:stops];
|
||||
return [[self alloc] initWithInterpolationBase:1 stops:stops];
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
return [self initWithBase:1 stops:@{}];
|
||||
return [self initWithInterpolationBase:1 stops:@{}];
|
||||
}
|
||||
|
||||
- (instancetype)initWithBase:(CGFloat)base stops:(NSDictionary *)stops {
|
||||
- (instancetype)initWithInterpolationBase:(CGFloat)interpolationBase stops:(NSDictionary *)stops {
|
||||
if (self = [super init]) {
|
||||
if (!stops.count)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException format:@"%@ requires at least one stop.", self];
|
||||
}
|
||||
_base = base;
|
||||
_interpolationBase = interpolationBase;
|
||||
_stops = stops;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)description {
|
||||
return [NSString stringWithFormat:@"<%@: %p, base = %f; stops = %@>",
|
||||
return [NSString stringWithFormat:@"<%@: %p, interpolationBase = %f; stops = %@>",
|
||||
NSStringFromClass([self class]), (void *)self,
|
||||
self.base,
|
||||
self.interpolationBase,
|
||||
self.stops];
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(MGLStyleFunction *)other {
|
||||
return ([other isKindOfClass:[self class]] && other.base == self.base
|
||||
return ([other isKindOfClass:[self class]] && other.interpolationBase == self.interpolationBase
|
||||
&& [other.stops isEqualToDictionary:self.stops]);
|
||||
}
|
||||
|
||||
- (NSUInteger)hash {
|
||||
return self.base + self.stops.hash;
|
||||
return self.interpolationBase + self.stops.hash;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
for (const auto &mbglStop : mbglStops) {
|
||||
stops[@(mbglStop.first)] = toEnumStyleConstantValue<>(mbglStop.second);
|
||||
}
|
||||
return [MGLStyleFunction<NSValue *> functionWithBase:mbglValue.asFunction().getBase() stops:stops];
|
||||
return [MGLStyleFunction<NSValue *> functionWithInterpolationBase:mbglValue.asFunction().getBase() stops:stops];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant());
|
||||
}];
|
||||
return mbgl::style::Function<MBGLType>({{mbglStops}}, function.base);
|
||||
return mbgl::style::Function<MBGLType>({{mbglStops}}, function.interpolationBase);
|
||||
} else if (value) {
|
||||
[NSException raise:@"MGLAbstractClassException" format:
|
||||
@"The style value %@ cannot be applied to the style. "
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant");
|
||||
mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant());
|
||||
}];
|
||||
return mbgl::style::Function<MBGLEnum>({{mbglStops}}, function.base);
|
||||
return mbgl::style::Function<MBGLEnum>({{mbglStops}}, function.interpolationBase);
|
||||
} else if (value) {
|
||||
[NSException raise:@"MGLAbstractClassException" format:
|
||||
@"The style value %@ cannot be applied to the style. "
|
||||
@@ -118,7 +118,7 @@ private:
|
||||
auto rawValue = toMGLRawStyleValue(mbglStop.second);
|
||||
stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue];
|
||||
}
|
||||
return [MGLStyleFunction<ObjCType> functionWithBase:mbglFunction.getBase() stops:stops];
|
||||
return [MGLStyleFunction<ObjCType> functionWithInterpolationBase:mbglFunction.getBase() stops:stops];
|
||||
}
|
||||
|
||||
template <typename MBGLEnum = MBGLType,
|
||||
|
||||
@@ -32,7 +32,7 @@ extension MGLStyleValueTests {
|
||||
3: MGLStyleValue(rawValue: true),
|
||||
4: MGLStyleValue(rawValue: false),
|
||||
]
|
||||
symbolStyleLayer.iconAllowsOverlap = MGLStyleFunction<NSNumber>(base: 1, stops: stops)
|
||||
XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(base: 1, stops: stops))
|
||||
symbolStyleLayer.iconAllowsOverlap = MGLStyleFunction<NSNumber>(interpolationBase: 1, stops: stops)
|
||||
XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(interpolationBase: 1, stops: stops))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user