#import "MGLStyleAttribute.h" #import "MGLStyleAttributeValue_Private.h" #import "MGLStyleAttributeFunction_Private.h" @interface MGLStyleAttribute() @end @implementation MGLStyleAttribute + (id)mbgl_colorWithPropertyValueColor:(mbgl::style::PropertyValue)property { if (property.isConstant()) { return [MGLColor mbgl_colorWithColor:property.asConstant()]; } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithColorPropertyValue:property.asFunction()]; } else { return nil; } } + (id )mbgl_numberWithPropertyValueNumber:(mbgl::style::PropertyValue)property { if (property.isConstant()) { return @(property.asConstant()); } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithNumberPropertyValue:property.asFunction()]; } else { return nil; } } + (id)mbgl_boolWithPropertyValueBool:(mbgl::style::PropertyValue)property { if (property.isConstant()) { return @(property.asConstant()); } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithBoolPropertyValue:property.asFunction()]; } else { return nil; } } + (id)mbgl_stringWithPropertyValueString:(mbgl::style::PropertyValue)property { if (property.isConstant()) { return @(property.asConstant().c_str()); } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithStringPropertyValue:property.asFunction()]; } else { return nil; } } + (id)mbgl_offsetWithPropertyValueOffset:(mbgl::style::PropertyValue >)property { if (property.isConstant()) { auto offset = property.asConstant(); return @[@(offset[0]), @(offset[1])]; } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithOffsetPropertyValue:property.asFunction()]; } else { return nil; } } + (id)mbgl_paddingWithPropertyValuePadding:(mbgl::style::PropertyValue >)property { if (property.isConstant()) { auto padding = property.asConstant(); return @[@(padding[0]), @(padding[1]), @(padding[2]), @(padding[3])]; } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithPaddingPropertyValue:property.asFunction()]; } else { return nil; } } + (id)mbgl_stringArrayWithPropertyValueStringArray:(mbgl::style::PropertyValue >)property { if (property.isConstant()) { auto strings = property.asConstant(); NSMutableArray *convertedStrings = [[NSMutableArray alloc] initWithCapacity:strings.size()]; for (auto string : strings) { [convertedStrings addObject:@(string.c_str())]; } return convertedStrings; } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithStringArrayPropertyValue:property.asFunction()]; } else { return nil; } } + (id)mbgl_numberArrayWithPropertyValueNumberArray:(mbgl::style::PropertyValue >)property { if (property.isConstant()) { auto numbers = property.asConstant(); NSMutableArray *convertedNumbers = [NSMutableArray arrayWithCapacity:numbers.size()]; for (auto number : numbers) { [convertedNumbers addObject:@(number)]; } return convertedNumbers; } else if (property.isFunction()) { return [MGLStyleAttributeFunction functionWithNumberArrayPropertyValue:property.asFunction()]; } else { return nil; } } @end