diff options
Diffstat (limited to 'platform/darwin/src')
-rw-r--r-- | platform/darwin/src/MGLStyleLayer.mm.ejs | 5 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyleValue_Private.h | 10 | ||||
-rw-r--r-- | platform/darwin/src/MGLSymbolStyleLayer.mm | 8 | ||||
-rw-r--r-- | platform/darwin/src/NSExpression+MGLAdditions.mm | 5 |
4 files changed, 24 insertions, 4 deletions
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 49ac04ce05..6d0c4bfdd9 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -125,8 +125,13 @@ namespace mbgl { if (<%- objCName(property) %> && <%- objCName(property) %>.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)<%- objCName(property) %>.constantValue).UTF8String; if (mbgl::style::conversion::hasTokens(string)) { +<% if (property.type === 'formatted') { -%> + self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbgl::style::PropertyValue<mbgl::style::expression::Formatted>( + mbgl::style::conversion::convertTokenStringToFormatExpression(string))); +<% } else { -%> self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbgl::style::PropertyValue<std::string>( mbgl::style::conversion::convertTokenStringToExpression(string))); +<% } -%> return; } } diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index 75e422fb45..cc1950bfb8 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -162,6 +162,11 @@ private: // Private utilities for converting from mgl to mbgl values mbglValue = rawValue.UTF8String; } + // Formatted + void getMBGLValue(NSString *rawValue, mbgl::style::expression::Formatted &mbglValue) { + mbglValue = mbgl::style::expression::Formatted(rawValue.UTF8String); + } + // Offsets void getMBGLValue(id rawValue, std::array<float, 2> &mbglValue) { if ([rawValue isKindOfClass:[NSValue class]]) { @@ -250,6 +255,11 @@ private: // Private utilities for converting from mbgl to mgl values return @(mbglStopValue.c_str()); } + // Formatted + static NSString *toMGLRawStyleValue(const mbgl::style::expression::Formatted &mbglStopValue) { + return @(mbglStopValue.toString().c_str()); + } + // Offsets static NSValue *toMGLRawStyleValue(const std::array<float, 2> &mbglStopValue) { return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 4c0fcfe539..e1bc7e7d20 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -601,12 +601,12 @@ namespace mbgl { if (text && text.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)text.constantValue).UTF8String; if (mbgl::style::conversion::hasTokens(string)) { - self.rawLayer->setTextField(mbgl::style::PropertyValue<std::string>( - mbgl::style::conversion::convertTokenStringToExpression(string))); + self.rawLayer->setTextField(mbgl::style::PropertyValue<mbgl::style::expression::Formatted>( + mbgl::style::conversion::convertTokenStringToFormatExpression(string))); return; } } - auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue<mbgl::style::PropertyValue<std::string>>(text, true); + auto mbglValue = MGLStyleValueTransformer<mbgl::style::expression::Formatted, NSString *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::expression::Formatted>>(text, true); self.rawLayer->setTextField(mbglValue); } @@ -617,7 +617,7 @@ namespace mbgl { if (propertyValue.isUndefined()) { propertyValue = self.rawLayer->getDefaultTextField(); } - return MGLStyleValueTransformer<std::string, NSString *>().toExpression(propertyValue); + return MGLStyleValueTransformer<mbgl::style::expression::Formatted, NSString *>().toExpression(propertyValue); } - (void)setTextField:(NSExpression *)textField { diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index 58f5816416..1a8dff060c 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -1111,6 +1111,11 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { // Avoid wrapping collator options object in literal expression. return @[@"collator", self.arguments[1].constantValue]; } + if (op.expressionType == NSConstantValueExpressionType + && [op.constantValue isEqualToString:@"format"]) { + // Avoid wrapping format options object in literal expression. + return @[@"format", self.arguments[1].mgl_jsonExpressionObject, self.arguments[2].constantValue]; + } return self.arguments.mgl_jsonExpressionObject; } else if (op == [MGLColor class] && [function isEqualToString:@"colorWithRed:green:blue:alpha:"]) { NSArray *arguments = self.arguments.mgl_jsonExpressionObject; |