From 3f26e88c49d3afeb3754a877b8473deb4bf2cded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 16 Dec 2016 08:09:42 -0800 Subject: Use appropriate part of speech for properties (#7457) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ios, macos] Use appropriate part of speech for properties Fixed overridden property references in requirements lists. Boolean-typed properties can now have getters beginning with “is”. Renamed a number of layout properties according to the following rules: Boolean-typed properties should include a verb; other properties must be noun phrases; all properties must be grammatical. * [ios, macos] Added style spec names as unavailable aliases Renamed properties now have aliases based on their style specification names, marked unavailable, for wayfinding purposes. * [ios, macos] Fixed autosynthesis warnings * [ios, macos] Moved style layer test template to test folder * [ios, macos] Customized iconOptional getter * [ios, macos] Avoid autosynthesis of aliases * [ios, macos] Test that property names are grammatical Run property getter names through a basic battery of tests to see if they’re grammatical. Most part-of-speech tagging tests are guarded by a compile-time flag, off by default, because NSLinguisticTagger does a poor job of telling nouns from verbs, and we’ve intentionally kept many words in property names that could be read as either verbs or nouns (like “transform” or “scale”). --- platform/darwin/scripts/generate-style-code.js | 45 ++-- .../scripts/style-spec-cocoa-conventions-v8.json | 19 +- platform/darwin/src/MGLBackgroundStyleLayer.mm | 2 +- platform/darwin/src/MGLCircleStyleLayer.mm | 2 +- platform/darwin/src/MGLFillStyleLayer.h | 9 +- platform/darwin/src/MGLFillStyleLayer.mm | 13 +- platform/darwin/src/MGLLineStyleLayer.h | 3 + platform/darwin/src/MGLLineStyleLayer.mm | 7 +- platform/darwin/src/MGLRasterStyleLayer.h | 9 + platform/darwin/src/MGLRasterStyleLayer.mm | 17 +- platform/darwin/src/MGLRuntimeStylingTests.m.ejs | 59 ----- platform/darwin/src/MGLStyleLayer.h.ejs | 12 +- platform/darwin/src/MGLStyleLayer.mm.ejs | 36 ++- platform/darwin/src/MGLSymbolStyleLayer.h | 174 +++++++++---- platform/darwin/src/MGLSymbolStyleLayer.mm | 282 +++++++++++++++------ .../src/NSValue+MGLStyleEnumAttributeAdditions.h | 8 +- .../src/NSValue+MGLStyleEnumAttributeAdditions.mm | 8 +- .../darwin/test/MGLBackgroundStyleLayerTests.m | 10 + platform/darwin/test/MGLCircleStyleLayerTests.m | 14 + platform/darwin/test/MGLFillStyleLayerTests.m | 22 +- platform/darwin/test/MGLLineStyleLayerTests.m | 21 ++ platform/darwin/test/MGLRasterStyleLayerTests.m | 14 + platform/darwin/test/MGLStyleLayerTests.h | 10 + platform/darwin/test/MGLStyleLayerTests.m | 67 +++++ platform/darwin/test/MGLStyleLayerTests.m.ejs | 72 ++++++ platform/darwin/test/MGLStyleValueTests.swift | 8 +- platform/darwin/test/MGLSymbolStyleLayerTests.m | 153 +++++++---- platform/ios/app/MBXViewController.m | 4 +- platform/ios/ios.xcodeproj/project.pbxproj | 4 +- platform/macos/macos.xcodeproj/project.pbxproj | 8 +- 30 files changed, 810 insertions(+), 302 deletions(-) delete mode 100644 platform/darwin/src/MGLRuntimeStylingTests.m.ejs create mode 100644 platform/darwin/test/MGLStyleLayerTests.m.ejs diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index de0e7d69a0..9e79d0a321 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -12,22 +12,33 @@ const suffix = 'StyleLayer'; // Rename properties and keep `original` for use with setters and getters _.forOwn(cocoaConventions, function (properties, kind) { _.forOwn(properties, function (newName, oldName) { - spec[kind][newName] = spec[kind][oldName]; - spec[kind][newName].original = oldName; + let property = spec[kind][oldName]; + if (newName.startsWith('is-')) { + property.getter = newName; + newName = newName.substr(3); + } + if (newName !== oldName) { + property.original = oldName; + } delete spec[kind][oldName]; + spec[kind][newName] = property; // Update requirements in other properties. let updateRequirements = function (property, name) { let requires = property.requires || []; for (let i = 0; i < requires.length; i++) { - if (requires[i] in cocoaConventions[kind]) { - property.requires[i] = cocoaConventions[kind][requires[i]]; + if (requires[i] === oldName) { + property.requires[i] = newName; + } + if (typeof requires[i] !== 'string') { + let prop = name; + _.forOwn(requires[i], function (values, name, require) { + if (name === oldName) { + require[newName] = values; + delete require[name]; + } + }); } - _.forOwn(requires[i], function (values, name, require) { - if (require in cocoaConventions[kind]) { - require[cocoaConventions[kind][name]] = values; - } - }); } }; _.forOwn(spec[kind.replace(/^layout_/, 'paint_')], updateRequirements); @@ -51,6 +62,10 @@ global.objCName = function (property) { return camelizeWithLeadingLowercase(property.name); } +global.objCGetter = function (property) { + return camelizeWithLeadingLowercase(property.getter || property.name); +} + global.objCType = function (layerType, propertyName) { return `${prefix}${camelize(propertyName)}`; } @@ -149,7 +164,7 @@ global.propertyDoc = function (propertyName, property, layerType) { return doc.replace(/(p)ixel/gi, '$1oint').replace(/(\d)px\b/g, '$1pt'); }; -global.propertyReqs = function (property, layoutPropertiesByName, type) { +global.propertyReqs = function (property, propertiesByName, type) { return 'This property is only applied to the style if ' + property.requires.map(function (req) { if (typeof req === 'string') { return '`' + camelizeWithLeadingLowercase(req) + '` is non-`nil`'; @@ -157,7 +172,7 @@ global.propertyReqs = function (property, layoutPropertiesByName, type) { return '`' + camelizeWithLeadingLowercase(req['!']) + '` is set to `nil`'; } else { let name = Object.keys(req)[0]; - return '`' + camelizeWithLeadingLowercase(name) + '` is set to an `MGLStyleValue` object containing ' + describeValue(req[name], layoutPropertiesByName[name], type); + return '`' + camelizeWithLeadingLowercase(name) + '` is set to an `MGLStyleValue` object containing ' + describeValue(req[name], propertiesByName[name], type); } }).join(', and ') + '. Otherwise, it is ignored.'; }; @@ -318,11 +333,11 @@ global.setSourceLayer = function() { } global.mbglType = function(property) { - let mbglType = camelize(property.name) + 'Type'; - if (/-translate-anchor$/.test(property.name)) { + let mbglType = camelize(originalPropertyName(property)) + 'Type'; + if (/-translate-anchor$/.test(originalPropertyName(property))) { mbglType = 'TranslateAnchorType'; } - if (/-(rotation|pitch)-alignment$/.test(property.name)) { + if (/-(rotation|pitch)-alignment$/.test(originalPropertyName(property))) { mbglType = 'AlignmentType'; } return mbglType; @@ -330,7 +345,7 @@ global.mbglType = function(property) { const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.ejs', 'utf8'), { strict: true }); const layerM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.mm.ejs', 'utf8'), { strict: true}); -const testLayers = ejs.compile(fs.readFileSync('platform/darwin/src/MGLRuntimeStylingTests.m.ejs', 'utf8'), { strict: true}); +const testLayers = ejs.compile(fs.readFileSync('platform/darwin/test/MGLStyleLayerTests.m.ejs', 'utf8'), { strict: true}); const categoryH = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h.ejs', 'utf8'), { strict: true}); const categoryM = ejs.compile(fs.readFileSync('platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm.ejs', 'utf8'), { strict: true}); diff --git a/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json b/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json index a144871a67..49cf515e3e 100644 --- a/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json +++ b/platform/darwin/scripts/style-spec-cocoa-conventions-v8.json @@ -1,7 +1,21 @@ { "layout_symbol": { + "icon-allow-overlap": "icon-allows-overlap", "icon-image": "icon-image-name", - "icon-size": "icon-scale" + "icon-ignore-placement": "icon-ignores-placement", + "icon-keep-upright": "keeps-icon-upright", + "icon-optional": "is-icon-optional", + "icon-rotate": "icon-rotation", + "icon-size": "icon-scale", + "symbol-avoid-edges": "symbol-avoids-edges", + "text-allow-overlap": "text-allows-overlap", + "text-ignore-placement": "text-ignores-placement", + "text-justify": "text-justification", + "text-keep-upright": "keeps-text-upright", + "text-max-angle": "maximum-text-angle", + "text-max-width": "maximum-text-width", + "text-optional": "is-text-optional", + "text-rotate": "text-rotation" }, "paint_raster": { "raster-brightness-min": "minimum-raster-brightness", @@ -10,5 +24,8 @@ }, "paint_line": { "line-dasharray": "line-dash-pattern" + }, + "paint_fill": { + "fill-antialias": "is-fill-antialiased" } } \ No newline at end of file diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 6a76f6072e..f6a00de941 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -41,7 +41,7 @@ super.rawLayer = rawLayer; } -#pragma mark - Adding to and removing from a map view +#pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index 0cd84453a2..266f2d836e 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -83,7 +83,7 @@ namespace mbgl { return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } -#pragma mark - Adding to and removing from a map view +#pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { diff --git a/platform/darwin/src/MGLFillStyleLayer.h b/platform/darwin/src/MGLFillStyleLayer.h index 9bbda26ce4..cf8c18b5c2 100644 --- a/platform/darwin/src/MGLFillStyleLayer.h +++ b/platform/darwin/src/MGLFillStyleLayer.h @@ -36,8 +36,13 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) { Whether or not the fill should be antialiased. The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. + + This attribute corresponds to the fill-antialias paint property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *fillAntialias; +@property (nonatomic, null_resettable, getter=isFillAntialiased) MGLStyleValue *fillAntialiased; + + +@property (nonatomic, null_resettable) MGLStyleValue *fillAntialias __attribute__((unavailable("Use fillAntialiased instead."))); #if TARGET_OS_IPHONE /** @@ -69,7 +74,7 @@ typedef NS_ENUM(NSUInteger, MGLFillTranslateAnchor) { /** The outline color of the fill. Matches the value of `fillColor` if unspecified. - This property is only applied to the style if `fillPattern` is set to `nil`, and `fillAntialias` is set to an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Otherwise, it is ignored. + This property is only applied to the style if `fillPattern` is set to `nil`, and `fillAntialiased` is set to an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Otherwise, it is ignored. */ @property (nonatomic, null_resettable) MGLStyleValue *fillOutlineColor; diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 47bd84fde7..891ab85d0b 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -78,7 +78,7 @@ namespace mbgl { return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } -#pragma mark - Adding to and removing from a map view +#pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { @@ -119,20 +119,25 @@ namespace mbgl { #pragma mark - Accessing the Paint Attributes -- (void)setFillAntialias:(MGLStyleValue *)fillAntialias { +- (void)setFillAntialiased:(MGLStyleValue *)fillAntialiased { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillAntialias); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillAntialiased); self.rawLayer->setFillAntialias(mbglValue); } -- (MGLStyleValue *)fillAntialias { +- (MGLStyleValue *)isFillAntialiased { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getFillAntialias() ?: self.rawLayer->getDefaultFillAntialias(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setFillAntialias:(MGLStyleValue *)fillAntialias { + NSAssert(NO, @"Use -setFillAntialiased: instead."); +} + - (void)setFillColor:(MGLStyleValue *)fillColor { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index fce7555272..c47c7d5166 100644 --- a/platform/darwin/src/MGLLineStyleLayer.h +++ b/platform/darwin/src/MGLLineStyleLayer.h @@ -146,6 +146,9 @@ typedef NS_ENUM(NSUInteger, MGLLineTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *> *lineDashPattern; + +@property (nonatomic, null_resettable) MGLStyleValue *> *lineDasharray __attribute__((unavailable("Use lineDashPattern instead."))); + /** Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index a23441c664..48164ed0c8 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -90,7 +90,7 @@ namespace mbgl { return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } -#pragma mark - Adding to and removing from a map view +#pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { @@ -231,6 +231,11 @@ namespace mbgl { return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(propertyValue); } + +- (void)setLineDasharray:(MGLStyleValue *> *)lineDasharray { + NSAssert(NO, @"Use -setLineDashPattern: instead."); +} + - (void)setLineGapWidth:(MGLStyleValue *)lineGapWidth { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index 916a0128d6..def5221d62 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.h +++ b/platform/darwin/src/MGLRasterStyleLayer.h @@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *maximumRasterBrightness; + +@property (nonatomic, null_resettable) MGLStyleValue *rasterBrightnessMax __attribute__((unavailable("Use maximumRasterBrightness instead."))); + /** Increase or reduce the brightness of the image. The value is the minimum brightness. @@ -34,6 +37,9 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *minimumRasterBrightness; + +@property (nonatomic, null_resettable) MGLStyleValue *rasterBrightnessMin __attribute__((unavailable("Use minimumRasterBrightness instead."))); + /** Increase or reduce the contrast of the image. @@ -61,6 +67,9 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, null_resettable) MGLStyleValue *rasterHueRotation; + +@property (nonatomic, null_resettable) MGLStyleValue *rasterHueRotate __attribute__((unavailable("Use rasterHueRotation instead."))); + /** The opacity at which the image will be drawn. diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index 9c2a64d0da..e61532773c 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -41,7 +41,7 @@ super.rawLayer = rawLayer; } -#pragma mark - Adding to and removing from a map view +#pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { @@ -96,6 +96,11 @@ return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setRasterBrightnessMax:(MGLStyleValue *)rasterBrightnessMax { + NSAssert(NO, @"Use -setMaximumRasterBrightness: instead."); +} + - (void)setMinimumRasterBrightness:(MGLStyleValue *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); @@ -110,6 +115,11 @@ return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setRasterBrightnessMin:(MGLStyleValue *)rasterBrightnessMin { + NSAssert(NO, @"Use -setMinimumRasterBrightness: instead."); +} + - (void)setRasterContrast:(MGLStyleValue *)rasterContrast { MGLAssertStyleLayerIsValid(); @@ -152,6 +162,11 @@ return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setRasterHueRotate:(MGLStyleValue *)rasterHueRotate { + NSAssert(NO, @"Use -setRasterHueRotation: instead."); +} + - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLRuntimeStylingTests.m.ejs b/platform/darwin/src/MGLRuntimeStylingTests.m.ejs deleted file mode 100644 index 91c626d1a2..0000000000 --- a/platform/darwin/src/MGLRuntimeStylingTests.m.ejs +++ /dev/null @@ -1,59 +0,0 @@ -<% - const type = locals.type; - const layoutProperties = locals.layoutProperties; - const paintProperties = locals.paintProperties; --%> -// This file is generated. -// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. - -#import "MGLStyleLayerTests.h" - -@interface MGL<%- camelize(type) %>LayerTests : MGLStyleLayerTests -@end - -@implementation MGL<%- camelize(type) %>LayerTests - -- (void)test<%- camelize(type) %>Layer { -<% if (type === 'background') { -%> - MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID"]; -<% } else { -%> - NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; - NSURL *url = [NSURL fileURLWithPath:filePath]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; - [self.mapView.style addSource:source]; - MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID" source:source]; -<% } -%> - [self.mapView.style addLayer:layer]; - -<% for (const property of layoutProperties) { -%> - <%- testImplementation(property, type) %> -<% } -%> -<% for (const property of paintProperties) { -%> - <%- testImplementation(property, type) %> -<% } -%> - - MGL<%- camelize(type) %>StyleLayer *gLayer = (MGL<%- camelize(type) %>StyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; - XCTAssertTrue([gLayer isKindOfClass:[MGL<%- camelize(type) %>StyleLayer class]]); -<% for (const property of layoutProperties) { -%> - <%- testGetterImplementation(property, type) %> -<% } -%> -<% for (const property of paintProperties) { -%> - <%- testGetterImplementation(property, type) %> -<% } -%> - -<% for (const property of layoutProperties) { -%> - <%- testImplementation(property, type, true) %> -<% } -%> -<% for (const property of paintProperties) { -%> - <%- testImplementation(property, type, true) %> -<% } -%> - -<% for (const property of layoutProperties) { -%> - <%- testGetterImplementation(property, type, true) %> -<% } -%> -<% for (const property of paintProperties) { -%> - <%- testGetterImplementation(property, type, true) %> -<% } -%> -} - -@end diff --git a/platform/darwin/src/MGLStyleLayer.h.ejs b/platform/darwin/src/MGLStyleLayer.h.ejs index d454ec0c6f..3b576e766b 100644 --- a/platform/darwin/src/MGLStyleLayer.h.ejs +++ b/platform/darwin/src/MGLStyleLayer.h.ejs @@ -96,8 +96,12 @@ typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) { This attribute corresponds to the <%- property.original -%> layout property in the Mapbox Style Specification. <% } -%> */ -@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } if (property.getter) { %>, getter=<%- objCGetter(property) -%><% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; +<% if (property.original) { %> +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> __attribute__((unavailable("Use <%- camelizeWithLeadingLowercase(property.name) %> instead."))); + +<% } -%> <% } -%> <% } -%> <% if (paintProperties.length) { -%> @@ -118,8 +122,12 @@ typedef NS_ENUM(NSUInteger, MGL<%- camelize(property.name) %>) { This attribute corresponds to the <%- property.original -%> paint property in the Mapbox Style Specification. <% } -%> */ -@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } if (property.getter) { %>, getter=<%- objCGetter(property) -%><% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(property.name) %>; +<% if (property.original) { %> +@property (nonatomic<% if (!property.required) { %>, null_resettable<% } %>) MGLStyleValue<<%- propertyType(property, true) %>> *<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> __attribute__((unavailable("Use <%- camelizeWithLeadingLowercase(property.name) %> instead."))); + +<% } -%> <% } -%> <% } -%> @end diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 3b446dd02e..6178eaad51 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -21,9 +21,9 @@ namespace mbgl { <% if (layoutProperties.length) { -%> <% for (const property of layoutProperties) { -%> <% if (property.type == "enum") { -%> - MBGL_DEFINE_ENUM(MGL<%- camelize(originalPropertyName(property)) %>, { + MBGL_DEFINE_ENUM(MGL<%- camelize(property.name) %>, { <% for (const value in property.values) { -%> - { MGL<%- camelize(originalPropertyName(property)) %><%- camelize(value) %>, "<%-value%>" }, + { MGL<%- camelize(property.name) %><%- camelize(value) %>, "<%-value%>" }, <% } -%> }); @@ -33,9 +33,9 @@ namespace mbgl { <% if (paintProperties.length) { -%> <% for (const property of paintProperties) { -%> <% if (property.type == "enum") { -%> - MBGL_DEFINE_ENUM(MGL<%- camelize(originalPropertyName(property)) %>, { + MBGL_DEFINE_ENUM(MGL<%- camelize(property.name) %>, { <% for (const value in property.values) { -%> - { MGL<%- camelize(originalPropertyName(property)) %><%- camelize(value) %>, "<%-value%>" }, + { MGL<%- camelize(property.name) %><%- camelize(value) %>, "<%-value%>" }, <% } -%> }); @@ -167,7 +167,7 @@ namespace mbgl { MGLAssertStyleLayerIsValid(); <% if (property.type == "enum") { -%> - auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); @@ -175,17 +175,27 @@ namespace mbgl { <% } -%> } -- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); <% if (property.type == "enum") { -%> - return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> } +<% if (property.original) { %> +- (void)set<%- camelize(originalPropertyName(property)) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + self.<%- camelizeWithLeadingLowercase(property.name) %> = <%- camelizeWithLeadingLowercase(originalPropertyName(property)) %>; +} + +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + return self.<%- objCGetter(property) %>; +} + +<% } -%> <% } -%> <% } -%> <% if (paintProperties.length) { -%> @@ -196,7 +206,7 @@ namespace mbgl { MGLAssertStyleLayerIsValid(); <% if (property.type == "enum") { -%> - auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); @@ -204,17 +214,23 @@ namespace mbgl { <% } -%> } -- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { +- (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); <% if (property.type == "enum") { -%> - return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> } +<% if (property.original) { %> +- (void)set<%- camelize(originalPropertyName(property)) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- camelizeWithLeadingLowercase(originalPropertyName(property)) %> { + NSAssert(NO, @"Use -set<%- camelize(property.name) %>: instead."); +} + +<% } -%> <% } -%> <% } -%> diff --git a/platform/darwin/src/MGLSymbolStyleLayer.h b/platform/darwin/src/MGLSymbolStyleLayer.h index 621339db75..5a216e0354 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.h +++ b/platform/darwin/src/MGLSymbolStyleLayer.h @@ -113,21 +113,21 @@ typedef NS_ENUM(NSUInteger, MGLTextAnchor) { /** Text justification options. - Values of this type are used in the `textJustify` property of `MGLSymbolStyleLayer`. + Values of this type are used in the `textJustification` property of `MGLSymbolStyleLayer`. */ -typedef NS_ENUM(NSUInteger, MGLTextJustify) { +typedef NS_ENUM(NSUInteger, MGLTextJustification) { /** The text is aligned to the left. */ - MGLTextJustifyLeft, + MGLTextJustificationLeft, /** The text is centered. */ - MGLTextJustifyCenter, + MGLTextJustificationCenter, /** The text is aligned to the right. */ - MGLTextJustifyRight, + MGLTextJustificationRight, }; /** @@ -238,8 +238,13 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the icon-allow-overlap layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *iconAllowOverlap; +@property (nonatomic, null_resettable) MGLStyleValue *iconAllowsOverlap; + + +@property (nonatomic, null_resettable) MGLStyleValue *iconAllowOverlap __attribute__((unavailable("Use iconAllowsOverlap instead."))); /** If true, other symbols can be visible even if they collide with the icon. @@ -247,8 +252,13 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the icon-ignore-placement layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *iconIgnorePlacement; +@property (nonatomic, null_resettable) MGLStyleValue *iconIgnoresPlacement; + + +@property (nonatomic, null_resettable) MGLStyleValue *iconIgnorePlacement __attribute__((unavailable("Use iconIgnoresPlacement instead."))); /** A string with {tokens} replaced, referencing the data property to pull from. @@ -257,14 +267,8 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *iconImageName; -/** - If true, the icon may be flipped to prevent it from being rendered upside-down. - - The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `iconImageName` is non-`nil`, and `iconRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. - */ -@property (nonatomic, null_resettable) MGLStyleValue *iconKeepUpright; + +@property (nonatomic, null_resettable) MGLStyleValue *iconImage __attribute__((unavailable("Use iconImageName instead."))); /** Offset distance of icon from its anchor. @@ -282,7 +286,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { This property is only applied to the style if `iconImageName` is non-`nil`, and `textField` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) MGLStyleValue *iconOptional; +@property (nonatomic, null_resettable, getter=isIconOptional) MGLStyleValue *iconOptional; /** Size of the additional area around the icon bounding box used for detecting symbol collisions. @@ -303,8 +307,13 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `iconImageName` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the icon-rotate layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *iconRotate; +@property (nonatomic, null_resettable) MGLStyleValue *iconRotation; + + +@property (nonatomic, null_resettable) MGLStyleValue *iconRotate __attribute__((unavailable("Use iconRotation instead."))); /** In combination with `symbolPlacement`, determines the rotation behavior of icons. @@ -326,6 +335,9 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *iconScale; + +@property (nonatomic, null_resettable) MGLStyleValue *iconSize __attribute__((unavailable("Use iconScale instead."))); + /** Scales the icon to fit around the associated text. @@ -346,12 +358,77 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *iconTextFitPadding; +/** + If true, the icon may be flipped to prevent it from being rendered upside-down. + + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + + This property is only applied to the style if `iconImageName` is non-`nil`, and `iconRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLIconRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + + This attribute corresponds to the icon-keep-upright layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue *keepsIconUpright; + + +@property (nonatomic, null_resettable) MGLStyleValue *iconKeepUpright __attribute__((unavailable("Use keepsIconUpright instead."))); + +/** + If true, the text may be flipped vertically to prevent it from being rendered upside-down. + + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. + + This property is only applied to the style if `textField` is non-`nil`, and `textRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + + This attribute corresponds to the text-keep-upright layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue *keepsTextUpright; + + +@property (nonatomic, null_resettable) MGLStyleValue *textKeepUpright __attribute__((unavailable("Use keepsTextUpright instead."))); + +/** + Maximum angle change between adjacent characters. + + This property is measured in degrees. + + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `45`. Set this property to `nil` to reset it to the default value. + + This property is only applied to the style if `textField` is non-`nil`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + + This attribute corresponds to the text-max-angle layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue *maximumTextAngle; + + +@property (nonatomic, null_resettable) MGLStyleValue *textMaxAngle __attribute__((unavailable("Use maximumTextAngle instead."))); + +/** + The maximum line width for text wrapping. + + This property is measured in ems. + + The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `10`. Set this property to `nil` to reset it to the default value. + + This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the text-max-width layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue *maximumTextWidth; + + +@property (nonatomic, null_resettable) MGLStyleValue *textMaxWidth __attribute__((unavailable("Use maximumTextWidth instead."))); + /** If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. + + This attribute corresponds to the symbol-avoid-edges layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *symbolAvoidEdges; +@property (nonatomic, null_resettable) MGLStyleValue *symbolAvoidsEdges; + + +@property (nonatomic, null_resettable) MGLStyleValue *symbolAvoidEdges __attribute__((unavailable("Use symbolAvoidsEdges instead."))); /** Label placement relative to its geometry. @@ -377,8 +454,13 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the text-allow-overlap layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *textAllowOverlap; +@property (nonatomic, null_resettable) MGLStyleValue *textAllowsOverlap; + + +@property (nonatomic, null_resettable) MGLStyleValue *textAllowOverlap __attribute__((unavailable("Use textAllowsOverlap instead."))); /** Part of the text placed closest to the anchor. @@ -411,26 +493,27 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `NO`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the text-ignore-placement layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *textIgnorePlacement; +@property (nonatomic, null_resettable) MGLStyleValue *textIgnoresPlacement; + + +@property (nonatomic, null_resettable) MGLStyleValue *textIgnorePlacement __attribute__((unavailable("Use textIgnoresPlacement instead."))); /** Text justification options. - The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextJustifyCenter`. Set this property to `nil` to reset it to the default value. + The default value of this property is an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextJustificationCenter`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. - */ -@property (nonatomic, null_resettable) MGLStyleValue *textJustify; - -/** - If true, the text may be flipped vertically to prevent it from being rendered upside-down. - - The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing `YES`. Set this property to `nil` to reset it to the default value. - This property is only applied to the style if `textField` is non-`nil`, and `textRotationAlignment` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLTextRotationAlignmentMap`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. + This attribute corresponds to the text-justify layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *textKeepUpright; +@property (nonatomic, null_resettable) MGLStyleValue *textJustification; + + +@property (nonatomic, null_resettable) MGLStyleValue *textJustify __attribute__((unavailable("Use textJustification instead."))); /** Text tracking amount. @@ -454,28 +537,6 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { */ @property (nonatomic, null_resettable) MGLStyleValue *textLineHeight; -/** - Maximum angle change between adjacent characters. - - This property is measured in degrees. - - The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `45`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `textField` is non-`nil`, and `symbolPlacement` is set to an `MGLStyleValue` object containing an `NSValue` object containing `MGLSymbolPlacementLine`. Otherwise, it is ignored. - */ -@property (nonatomic, null_resettable) MGLStyleValue *textMaxAngle; - -/** - The maximum line width for text wrapping. - - This property is measured in ems. - - The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `10`. Set this property to `nil` to reset it to the default value. - - This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. - */ -@property (nonatomic, null_resettable) MGLStyleValue *textMaxWidth; - /** Offset distance of text from its anchor. @@ -494,7 +555,7 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { This property is only applied to the style if `textField` is non-`nil`, and `iconImageName` is non-`nil`. Otherwise, it is ignored. */ -@property (nonatomic, null_resettable) MGLStyleValue *textOptional; +@property (nonatomic, null_resettable, getter=isTextOptional) MGLStyleValue *textOptional; /** Size of the additional area around the text bounding box used for detecting symbol collisions. @@ -524,8 +585,13 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { The default value of this property is an `MGLStyleValue` object containing an `NSNumber` object containing the float `0`. Set this property to `nil` to reset it to the default value. This property is only applied to the style if `textField` is non-`nil`. Otherwise, it is ignored. + + This attribute corresponds to the text-rotate layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue *textRotate; +@property (nonatomic, null_resettable) MGLStyleValue *textRotation; + + +@property (nonatomic, null_resettable) MGLStyleValue *textRotate __attribute__((unavailable("Use textRotation instead."))); /** In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text. diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index af92c6ba67..31c584b473 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -41,10 +41,10 @@ namespace mbgl { { MGLTextAnchorBottomRight, "bottom-right" }, }); - MBGL_DEFINE_ENUM(MGLTextJustify, { - { MGLTextJustifyLeft, "left" }, - { MGLTextJustifyCenter, "center" }, - { MGLTextJustifyRight, "right" }, + MBGL_DEFINE_ENUM(MGLTextJustification, { + { MGLTextJustificationLeft, "left" }, + { MGLTextJustificationCenter, "center" }, + { MGLTextJustificationRight, "right" }, }); MBGL_DEFINE_ENUM(MGLTextPitchAlignment, { @@ -137,7 +137,7 @@ namespace mbgl { return [NSPredicate mgl_predicateWithFilter:self.rawLayer->getFilter()]; } -#pragma mark - Adding to and removing from a map view +#pragma mark - Adding to and removing from a map view - (void)addToMapView:(MGLMapView *)mapView belowLayer:(MGLStyleLayer *)otherLayer { @@ -178,34 +178,52 @@ namespace mbgl { #pragma mark - Accessing the Layout Attributes -- (void)setIconAllowOverlap:(MGLStyleValue *)iconAllowOverlap { +- (void)setIconAllowsOverlap:(MGLStyleValue *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconAllowOverlap); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconAllowsOverlap); self.rawLayer->setIconAllowOverlap(mbglValue); } -- (MGLStyleValue *)iconAllowOverlap { +- (MGLStyleValue *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconAllowOverlap() ?: self.rawLayer->getDefaultIconAllowOverlap(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconIgnorePlacement:(MGLStyleValue *)iconIgnorePlacement { + +- (void)setIconAllowOverlap:(MGLStyleValue *)iconAllowOverlap { + self.iconAllowsOverlap = iconAllowOverlap; +} + +- (MGLStyleValue *)iconAllowOverlap { + return self.iconAllowsOverlap; +} + +- (void)setIconIgnoresPlacement:(MGLStyleValue *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconIgnorePlacement); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconIgnoresPlacement); self.rawLayer->setIconIgnorePlacement(mbglValue); } -- (MGLStyleValue *)iconIgnorePlacement { +- (MGLStyleValue *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconIgnorePlacement() ?: self.rawLayer->getDefaultIconIgnorePlacement(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setIconIgnorePlacement:(MGLStyleValue *)iconIgnorePlacement { + self.iconIgnoresPlacement = iconIgnorePlacement; +} + +- (MGLStyleValue *)iconIgnorePlacement { + return self.iconIgnoresPlacement; +} + - (void)setIconImageName:(MGLStyleValue *)iconImageName { MGLAssertStyleLayerIsValid(); @@ -220,18 +238,13 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconKeepUpright:(MGLStyleValue *)iconKeepUpright { - MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconKeepUpright); - self.rawLayer->setIconKeepUpright(mbglValue); +- (void)setIconImage:(MGLStyleValue *)iconImage { + self.iconImageName = iconImage; } -- (MGLStyleValue *)iconKeepUpright { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); +- (MGLStyleValue *)iconImage { + return self.iconImageName; } - (void)setIconOffset:(MGLStyleValue *)iconOffset { @@ -255,7 +268,7 @@ namespace mbgl { self.rawLayer->setIconOptional(mbglValue); } -- (MGLStyleValue *)iconOptional { +- (MGLStyleValue *)isIconOptional { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconOptional() ?: self.rawLayer->getDefaultIconOptional(); @@ -276,20 +289,29 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setIconRotate:(MGLStyleValue *)iconRotate { +- (void)setIconRotation:(MGLStyleValue *)iconRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotate); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotation); self.rawLayer->setIconRotate(mbglValue); } -- (MGLStyleValue *)iconRotate { +- (MGLStyleValue *)iconRotation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconRotate() ?: self.rawLayer->getDefaultIconRotate(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setIconRotate:(MGLStyleValue *)iconRotate { + self.iconRotation = iconRotate; +} + +- (MGLStyleValue *)iconRotate { + return self.iconRotation; +} + - (void)setIconRotationAlignment:(MGLStyleValue *)iconRotationAlignment { MGLAssertStyleLayerIsValid(); @@ -318,6 +340,15 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setIconSize:(MGLStyleValue *)iconSize { + self.iconScale = iconSize; +} + +- (MGLStyleValue *)iconSize { + return self.iconScale; +} + - (void)setIconTextFit:(MGLStyleValue *)iconTextFit { MGLAssertStyleLayerIsValid(); @@ -346,20 +377,121 @@ namespace mbgl { return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } -- (void)setSymbolAvoidEdges:(MGLStyleValue *)symbolAvoidEdges { +- (void)setKeepsIconUpright:(MGLStyleValue *)keepsIconUpright { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(keepsIconUpright); + self.rawLayer->setIconKeepUpright(mbglValue); +} + +- (MGLStyleValue *)keepsIconUpright { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); +} + + +- (void)setIconKeepUpright:(MGLStyleValue *)iconKeepUpright { + self.keepsIconUpright = iconKeepUpright; +} + +- (MGLStyleValue *)iconKeepUpright { + return self.keepsIconUpright; +} + +- (void)setKeepsTextUpright:(MGLStyleValue *)keepsTextUpright { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(keepsTextUpright); + self.rawLayer->setTextKeepUpright(mbglValue); +} + +- (MGLStyleValue *)keepsTextUpright { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); +} + + +- (void)setTextKeepUpright:(MGLStyleValue *)textKeepUpright { + self.keepsTextUpright = textKeepUpright; +} + +- (MGLStyleValue *)textKeepUpright { + return self.keepsTextUpright; +} + +- (void)setMaximumTextAngle:(MGLStyleValue *)maximumTextAngle { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(maximumTextAngle); + self.rawLayer->setTextMaxAngle(mbglValue); +} + +- (MGLStyleValue *)maximumTextAngle { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); +} + + +- (void)setTextMaxAngle:(MGLStyleValue *)textMaxAngle { + self.maximumTextAngle = textMaxAngle; +} + +- (MGLStyleValue *)textMaxAngle { + return self.maximumTextAngle; +} + +- (void)setMaximumTextWidth:(MGLStyleValue *)maximumTextWidth { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(maximumTextWidth); + self.rawLayer->setTextMaxWidth(mbglValue); +} + +- (MGLStyleValue *)maximumTextWidth { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth(); + return MGLStyleValueTransformer().toStyleValue(propertyValue); +} + + +- (void)setTextMaxWidth:(MGLStyleValue *)textMaxWidth { + self.maximumTextWidth = textMaxWidth; +} + +- (MGLStyleValue *)textMaxWidth { + return self.maximumTextWidth; +} + +- (void)setSymbolAvoidsEdges:(MGLStyleValue *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolAvoidEdges); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(symbolAvoidsEdges); self.rawLayer->setSymbolAvoidEdges(mbglValue); } -- (MGLStyleValue *)symbolAvoidEdges { +- (MGLStyleValue *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getSymbolAvoidEdges() ?: self.rawLayer->getDefaultSymbolAvoidEdges(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setSymbolAvoidEdges:(MGLStyleValue *)symbolAvoidEdges { + self.symbolAvoidsEdges = symbolAvoidEdges; +} + +- (MGLStyleValue *)symbolAvoidEdges { + return self.symbolAvoidsEdges; +} + - (void)setSymbolPlacement:(MGLStyleValue *)symbolPlacement { MGLAssertStyleLayerIsValid(); @@ -388,20 +520,29 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextAllowOverlap:(MGLStyleValue *)textAllowOverlap { +- (void)setTextAllowsOverlap:(MGLStyleValue *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textAllowOverlap); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textAllowsOverlap); self.rawLayer->setTextAllowOverlap(mbglValue); } -- (MGLStyleValue *)textAllowOverlap { +- (MGLStyleValue *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextAllowOverlap() ?: self.rawLayer->getDefaultTextAllowOverlap(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setTextAllowOverlap:(MGLStyleValue *)textAllowOverlap { + self.textAllowsOverlap = textAllowOverlap; +} + +- (MGLStyleValue *)textAllowOverlap { + return self.textAllowsOverlap; +} + - (void)setTextAnchor:(MGLStyleValue *)textAnchor { MGLAssertStyleLayerIsValid(); @@ -444,46 +585,50 @@ namespace mbgl { return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(propertyValue); } -- (void)setTextIgnorePlacement:(MGLStyleValue *)textIgnorePlacement { +- (void)setTextIgnoresPlacement:(MGLStyleValue *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textIgnorePlacement); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textIgnoresPlacement); self.rawLayer->setTextIgnorePlacement(mbglValue); } -- (MGLStyleValue *)textIgnorePlacement { +- (MGLStyleValue *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextIgnorePlacement() ?: self.rawLayer->getDefaultTextIgnorePlacement(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextJustify:(MGLStyleValue *)textJustify { + +- (void)setTextIgnorePlacement:(MGLStyleValue *)textIgnorePlacement { + self.textIgnoresPlacement = textIgnorePlacement; +} + +- (MGLStyleValue *)textIgnorePlacement { + return self.textIgnoresPlacement; +} + +- (void)setTextJustification:(MGLStyleValue *)textJustification { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(textJustify); + auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(textJustification); self.rawLayer->setTextJustify(mbglValue); } -- (MGLStyleValue *)textJustify { +- (MGLStyleValue *)textJustification { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextJustify() ?: self.rawLayer->getDefaultTextJustify(); - return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -- (void)setTextKeepUpright:(MGLStyleValue *)textKeepUpright { - MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textKeepUpright); - self.rawLayer->setTextKeepUpright(mbglValue); +- (void)setTextJustify:(MGLStyleValue *)textJustify { + self.textJustification = textJustify; } -- (MGLStyleValue *)textKeepUpright { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); +- (MGLStyleValue *)textJustify { + return self.textJustification; } - (void)setTextLetterSpacing:(MGLStyleValue *)textLetterSpacing { @@ -514,34 +659,6 @@ namespace mbgl { return MGLStyleValueTransformer().toStyleValue(propertyValue); } -- (void)setTextMaxAngle:(MGLStyleValue *)textMaxAngle { - MGLAssertStyleLayerIsValid(); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textMaxAngle); - self.rawLayer->setTextMaxAngle(mbglValue); -} - -- (MGLStyleValue *)textMaxAngle { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); -} - -- (void)setTextMaxWidth:(MGLStyleValue *)textMaxWidth { - MGLAssertStyleLayerIsValid(); - - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textMaxWidth); - self.rawLayer->setTextMaxWidth(mbglValue); -} - -- (MGLStyleValue *)textMaxWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); -} - - (void)setTextOffset:(MGLStyleValue *)textOffset { MGLAssertStyleLayerIsValid(); @@ -563,7 +680,7 @@ namespace mbgl { self.rawLayer->setTextOptional(mbglValue); } -- (MGLStyleValue *)textOptional { +- (MGLStyleValue *)isTextOptional { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextOptional() ?: self.rawLayer->getDefaultTextOptional(); @@ -598,20 +715,29 @@ namespace mbgl { return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -- (void)setTextRotate:(MGLStyleValue *)textRotate { +- (void)setTextRotation:(MGLStyleValue *)textRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textRotate); + auto mbglValue = MGLStyleValueTransformer().toPropertyValue(textRotation); self.rawLayer->setTextRotate(mbglValue); } -- (MGLStyleValue *)textRotate { +- (MGLStyleValue *)textRotation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextRotate() ?: self.rawLayer->getDefaultTextRotate(); return MGLStyleValueTransformer().toStyleValue(propertyValue); } + +- (void)setTextRotate:(MGLStyleValue *)textRotate { + self.textRotation = textRotate; +} + +- (MGLStyleValue *)textRotate { + return self.textRotation; +} + - (void)setTextRotationAlignment:(MGLStyleValue *)textRotationAlignment { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h index 8aa07b2a0c..3387ce8188 100644 --- a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h +++ b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h @@ -98,17 +98,17 @@ NS_ASSUME_NONNULL_BEGIN @property (readonly) MGLTextAnchor MGLTextAnchorValue; /** - Creates a new value object containing the given `MGLTextJustify` enumeration. + Creates a new value object containing the given `MGLTextJustification` enumeration. @param type The value for the new object. @return A new value object that contains the style enumeration type. */ -+ (instancetype)valueWithMGLTextJustify:(MGLTextJustify)textJustify; ++ (instancetype)valueWithMGLTextJustification:(MGLTextJustification)textJustification; /** - The `MGLTextJustify` enumeration representation of the value. + The `MGLTextJustification` enumeration representation of the value. */ -@property (readonly) MGLTextJustify MGLTextJustifyValue; +@property (readonly) MGLTextJustification MGLTextJustificationValue; /** Creates a new value object containing the given `MGLTextPitchAlignment` enumeration. diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm index 89f0c07a5a..db91408c5a 100644 --- a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.mm @@ -65,12 +65,12 @@ return value; } -+ (NSValue *)valueWithMGLTextJustify:(MGLTextJustify)textJustify { - return [NSValue value:&textJustify withObjCType:@encode(MGLTextJustify)]; ++ (NSValue *)valueWithMGLTextJustification:(MGLTextJustification)textJustification { + return [NSValue value:&textJustification withObjCType:@encode(MGLTextJustification)]; } -- (MGLTextJustify)MGLTextJustifyValue { - MGLTextJustify value; +- (MGLTextJustification)MGLTextJustificationValue { + MGLTextJustification value; [self getValue:&value]; return value; } diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.m b/platform/darwin/test/MGLBackgroundStyleLayerTests.m index 09bed76654..934021d6b8 100644 --- a/platform/darwin/test/MGLBackgroundStyleLayerTests.m +++ b/platform/darwin/test/MGLBackgroundStyleLayerTests.m @@ -8,6 +8,10 @@ @implementation MGLBackgroundLayerTests ++ (NSString *)layerType { + return @"background"; +} + - (void)testBackgroundLayer { MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"layerID"]; [self.mapView.style addLayer:layer]; @@ -31,4 +35,10 @@ XCTAssertEqualObjects(gLayer.backgroundPattern, [MGLRuntimeStylingHelper testStringFunction]); } +- (void)testPropertyNames { + [self testPropertyName:@"background-color" isBoolean:NO]; + [self testPropertyName:@"background-opacity" isBoolean:NO]; + [self testPropertyName:@"background-pattern" isBoolean:NO]; +} + @end diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.m b/platform/darwin/test/MGLCircleStyleLayerTests.m index f98e731354..66c05f15c9 100644 --- a/platform/darwin/test/MGLCircleStyleLayerTests.m +++ b/platform/darwin/test/MGLCircleStyleLayerTests.m @@ -8,6 +8,10 @@ @implementation MGLCircleLayerTests ++ (NSString *)layerType { + return @"circle"; +} + - (void)testCircleLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; @@ -53,4 +57,14 @@ XCTAssertEqualObjects(gLayer.circleTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLCircleTranslateAnchorViewport type:@encode(MGLCircleTranslateAnchor)]); } +- (void)testPropertyNames { + [self testPropertyName:@"circle-blur" isBoolean:NO]; + [self testPropertyName:@"circle-color" isBoolean:NO]; + [self testPropertyName:@"circle-opacity" isBoolean:NO]; + [self testPropertyName:@"circle-pitch-scale" isBoolean:NO]; + [self testPropertyName:@"circle-radius" isBoolean:NO]; + [self testPropertyName:@"circle-translate" isBoolean:NO]; + [self testPropertyName:@"circle-translate-anchor" isBoolean:NO]; +} + @end diff --git a/platform/darwin/test/MGLFillStyleLayerTests.m b/platform/darwin/test/MGLFillStyleLayerTests.m index dd16214a71..7d51c15cf4 100644 --- a/platform/darwin/test/MGLFillStyleLayerTests.m +++ b/platform/darwin/test/MGLFillStyleLayerTests.m @@ -8,6 +8,10 @@ @implementation MGLFillLayerTests ++ (NSString *)layerType { + return @"fill"; +} + - (void)testFillLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; @@ -16,7 +20,7 @@ MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; - layer.fillAntialias = [MGLRuntimeStylingHelper testBool]; + layer.fillAntialiased = [MGLRuntimeStylingHelper testBool]; layer.fillColor = [MGLRuntimeStylingHelper testColor]; layer.fillOpacity = [MGLRuntimeStylingHelper testNumber]; layer.fillOutlineColor = [MGLRuntimeStylingHelper testColor]; @@ -26,7 +30,7 @@ MGLFillStyleLayer *gLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; XCTAssertTrue([gLayer isKindOfClass:[MGLFillStyleLayer class]]); - XCTAssertEqualObjects(gLayer.fillAntialias, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.fillAntialiased, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.fillColor, [MGLRuntimeStylingHelper testColor]); XCTAssertEqualObjects(gLayer.fillOpacity, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.fillOutlineColor, [MGLRuntimeStylingHelper testColor]); @@ -35,7 +39,7 @@ XCTAssert([gLayer.fillTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]); - layer.fillAntialias = [MGLRuntimeStylingHelper testBoolFunction]; + layer.fillAntialiased = [MGLRuntimeStylingHelper testBoolFunction]; layer.fillColor = [MGLRuntimeStylingHelper testColorFunction]; layer.fillOpacity = [MGLRuntimeStylingHelper testNumberFunction]; layer.fillOutlineColor = [MGLRuntimeStylingHelper testColorFunction]; @@ -43,7 +47,7 @@ layer.fillTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; layer.fillTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]; - XCTAssertEqualObjects(gLayer.fillAntialias, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.fillAntialiased, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.fillColor, [MGLRuntimeStylingHelper testColorFunction]); XCTAssertEqualObjects(gLayer.fillOpacity, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.fillOutlineColor, [MGLRuntimeStylingHelper testColorFunction]); @@ -52,4 +56,14 @@ XCTAssertEqualObjects(gLayer.fillTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLFillTranslateAnchorViewport type:@encode(MGLFillTranslateAnchor)]); } +- (void)testPropertyNames { + [self testPropertyName:@"is-fill-antialiased" isBoolean:YES]; + [self testPropertyName:@"fill-color" isBoolean:NO]; + [self testPropertyName:@"fill-opacity" isBoolean:NO]; + [self testPropertyName:@"fill-outline-color" isBoolean:NO]; + [self testPropertyName:@"fill-pattern" isBoolean:NO]; + [self testPropertyName:@"fill-translate" isBoolean:NO]; + [self testPropertyName:@"fill-translate-anchor" isBoolean:NO]; +} + @end diff --git a/platform/darwin/test/MGLLineStyleLayerTests.m b/platform/darwin/test/MGLLineStyleLayerTests.m index 49dd1f2198..e877c1d57a 100644 --- a/platform/darwin/test/MGLLineStyleLayerTests.m +++ b/platform/darwin/test/MGLLineStyleLayerTests.m @@ -8,6 +8,10 @@ @implementation MGLLineLayerTests ++ (NSString *)layerType { + return @"line"; +} + - (void)testLineLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; @@ -82,4 +86,21 @@ XCTAssertEqualObjects(gLayer.lineWidth, [MGLRuntimeStylingHelper testNumberFunction]); } +- (void)testPropertyNames { + [self testPropertyName:@"line-cap" isBoolean:NO]; + [self testPropertyName:@"line-join" isBoolean:NO]; + [self testPropertyName:@"line-miter-limit" isBoolean:NO]; + [self testPropertyName:@"line-round-limit" isBoolean:NO]; + [self testPropertyName:@"line-blur" isBoolean:NO]; + [self testPropertyName:@"line-color" isBoolean:NO]; + [self testPropertyName:@"line-dash-pattern" isBoolean:NO]; + [self testPropertyName:@"line-gap-width" isBoolean:NO]; + [self testPropertyName:@"line-offset" isBoolean:NO]; + [self testPropertyName:@"line-opacity" isBoolean:NO]; + [self testPropertyName:@"line-pattern" isBoolean:NO]; + [self testPropertyName:@"line-translate" isBoolean:NO]; + [self testPropertyName:@"line-translate-anchor" isBoolean:NO]; + [self testPropertyName:@"line-width" isBoolean:NO]; +} + @end diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.m b/platform/darwin/test/MGLRasterStyleLayerTests.m index 485664c986..f8de191da0 100644 --- a/platform/darwin/test/MGLRasterStyleLayerTests.m +++ b/platform/darwin/test/MGLRasterStyleLayerTests.m @@ -8,6 +8,10 @@ @implementation MGLRasterLayerTests ++ (NSString *)layerType { + return @"raster"; +} + - (void)testRasterLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; @@ -51,4 +55,14 @@ XCTAssertEqualObjects(gLayer.rasterSaturation, [MGLRuntimeStylingHelper testNumberFunction]); } +- (void)testPropertyNames { + [self testPropertyName:@"maximum-raster-brightness" isBoolean:NO]; + [self testPropertyName:@"minimum-raster-brightness" isBoolean:NO]; + [self testPropertyName:@"raster-contrast" isBoolean:NO]; + [self testPropertyName:@"raster-fade-duration" isBoolean:NO]; + [self testPropertyName:@"raster-hue-rotation" isBoolean:NO]; + [self testPropertyName:@"raster-opacity" isBoolean:NO]; + [self testPropertyName:@"raster-saturation" isBoolean:NO]; +} + @end diff --git a/platform/darwin/test/MGLStyleLayerTests.h b/platform/darwin/test/MGLStyleLayerTests.h index f81e075e03..74ce62e894 100644 --- a/platform/darwin/test/MGLStyleLayerTests.h +++ b/platform/darwin/test/MGLStyleLayerTests.h @@ -6,5 +6,15 @@ @property (nonatomic) IBOutlet MGLMapView *mapView; @property (nonatomic) XCTestExpectation *expectation; +@property (nonatomic, copy, readonly, class) NSString *layerType; + +- (void)testPropertyName:(NSString *)name isBoolean:(BOOL)isBoolean; + +@end + +@interface NSString (MGLStyleLayerTestAdditions) + +@property (nonatomic, readonly, copy) NS_ARRAY_OF(NSString *) *lexicalClasses; +@property (nonatomic, readonly, copy) NSString *lemma; @end diff --git a/platform/darwin/test/MGLStyleLayerTests.m b/platform/darwin/test/MGLStyleLayerTests.m index 74c6b2f906..590d6eda7f 100644 --- a/platform/darwin/test/MGLStyleLayerTests.m +++ b/platform/darwin/test/MGLStyleLayerTests.m @@ -1,7 +1,13 @@ #import "MGLStyleLayerTests.h" +#import "NSString+MGLAdditions.h" + +#define TEST_STRICT_NAMING_CONVENTIONS 0 + @implementation MGLStyleLayerTests +@dynamic layerType; + - (void)setUp { [super setUp]; #if TARGET_OS_IPHONE @@ -19,4 +25,65 @@ #endif } +- (void)testPropertyName:(NSString *)name isBoolean:(BOOL)isBoolean { + NS_MUTABLE_ARRAY_OF(NSString *) *components = [name componentsSeparatedByString:@"-"].mutableCopy; + if (isBoolean) { + if ([components.firstObject isEqualToString:@"is"]) { + [components removeObjectAtIndex:0]; + if (![components.lastObject.lexicalClasses containsObject:NSLinguisticTagAdjective]) { + XCTAssertTrue([components.lastObject.lexicalClasses containsObject:NSLinguisticTagVerb], + @"Boolean getter %@ that starts with “is” should contain an adjective, past participle, or verb.", name); + XCTAssertNotEqualObjects(components.lastObject.lemma, components.lastObject, + @"Boolean getter %@ should not have infinitive, imperative, or present tense verb.", name); + } + } else { + if ([components.firstObject isEqualToString:[self class].layerType] + || [components.firstObject isEqualToString:@"icon"] || [components.firstObject isEqualToString:@"text"]) { + [components removeObjectAtIndex:0]; + } +#if TEST_STRICT_NAMING_CONVENTIONS + XCTAssertTrue([components.firstObject.lexicalClasses containsObject:NSLinguisticTagVerb], + @"Boolean getter %@ that doesn’t start with “is” should contain a verb.", name); + XCTAssertNotEqualObjects(components.firstObject.lemma, components.lastObject); +#endif + } + } else { + XCTAssertFalse([components.firstObject isEqualToString:@"is"]); +#if TEST_STRICT_NAMING_CONVENTIONS + XCTAssertTrue([components.lastObject.lexicalClasses containsObject:NSLinguisticTagNoun], + @"Non-Boolean getter %@ should contain a noun.", name); +#endif + } +} + +@end + +@implementation NSString (MGLStyleLayerTestAdditions) + +- (NS_ARRAY_OF(NSString *) *)lexicalClasses { + NSOrthography *orthography = [NSOrthography orthographyWithDominantScript:@"Latn" + languageMap:@{@"Latn": @[@"en"]}]; + NSLinguisticTaggerOptions options = (NSLinguisticTaggerOmitPunctuation + | NSLinguisticTaggerOmitWhitespace + | NSLinguisticTaggerOmitOther); + return [self linguisticTagsInRange:self.mgl_wholeRange + scheme:NSLinguisticTagSchemeLexicalClass + options:options + orthography:orthography + tokenRanges:NULL]; +} + +- (NSString *)lemma { + NSOrthography *orthography = [NSOrthography orthographyWithDominantScript:@"Latn" + languageMap:@{@"Latn": @[@"en"]}]; + NSLinguisticTaggerOptions options = (NSLinguisticTaggerOmitPunctuation + | NSLinguisticTaggerOmitWhitespace + | NSLinguisticTaggerOmitOther); + return [self linguisticTagsInRange:self.mgl_wholeRange + scheme:NSLinguisticTagSchemeLemma + options:options + orthography:orthography + tokenRanges:NULL].firstObject; +} + @end diff --git a/platform/darwin/test/MGLStyleLayerTests.m.ejs b/platform/darwin/test/MGLStyleLayerTests.m.ejs new file mode 100644 index 0000000000..6b7bfe2f1c --- /dev/null +++ b/platform/darwin/test/MGLStyleLayerTests.m.ejs @@ -0,0 +1,72 @@ +<% + const type = locals.type; + const layoutProperties = locals.layoutProperties; + const paintProperties = locals.paintProperties; +-%> +// This file is generated. +// Edit platform/darwin/scripts/generate-style-code.js, then run `make style-code-darwin`. + +#import "MGLStyleLayerTests.h" + +@interface MGL<%- camelize(type) %>LayerTests : MGLStyleLayerTests +@end + +@implementation MGL<%- camelize(type) %>LayerTests + ++ (NSString *)layerType { + return @"<%- type %>"; +} + +- (void)test<%- camelize(type) %>Layer { +<% if (type === 'background') { -%> + MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID"]; +<% } else { -%> + NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; + NSURL *url = [NSURL fileURLWithPath:filePath]; + MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" URL:url options:nil]; + [self.mapView.style addSource:source]; + MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID" source:source]; +<% } -%> + [self.mapView.style addLayer:layer]; + +<% for (const property of layoutProperties) { -%> + <%- testImplementation(property, type) %> +<% } -%> +<% for (const property of paintProperties) { -%> + <%- testImplementation(property, type) %> +<% } -%> + + MGL<%- camelize(type) %>StyleLayer *gLayer = (MGL<%- camelize(type) %>StyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; + XCTAssertTrue([gLayer isKindOfClass:[MGL<%- camelize(type) %>StyleLayer class]]); +<% for (const property of layoutProperties) { -%> + <%- testGetterImplementation(property, type) %> +<% } -%> +<% for (const property of paintProperties) { -%> + <%- testGetterImplementation(property, type) %> +<% } -%> + +<% for (const property of layoutProperties) { -%> + <%- testImplementation(property, type, true) %> +<% } -%> +<% for (const property of paintProperties) { -%> + <%- testImplementation(property, type, true) %> +<% } -%> + +<% for (const property of layoutProperties) { -%> + <%- testGetterImplementation(property, type, true) %> +<% } -%> +<% for (const property of paintProperties) { -%> + <%- testGetterImplementation(property, type, true) %> +<% } -%> +} + +- (void)testPropertyNames { +<% for (const property of layoutProperties) { -%> + [self testPropertyName:@"<%- property.getter || property.name %>" isBoolean:<%- property.type === 'boolean' ? 'YES' : 'NO' %>]; +<% } -%> +<% for (const property of paintProperties) { -%> + [self testPropertyName:@"<%- property.getter || property.name %>" isBoolean:<%- property.type === 'boolean' ? 'YES' : 'NO' %>]; +<% } -%> +} + +@end diff --git a/platform/darwin/test/MGLStyleValueTests.swift b/platform/darwin/test/MGLStyleValueTests.swift index e529af0634..bf01435114 100644 --- a/platform/darwin/test/MGLStyleValueTests.swift +++ b/platform/darwin/test/MGLStyleValueTests.swift @@ -9,8 +9,8 @@ extension MGLStyleValueTests { let symbolStyleLayer = MGLSymbolStyleLayer(identifier: "test", source: shapeSource) // Boolean - symbolStyleLayer.iconAllowOverlap = MGLStyleConstantValue(rawValue: true) - XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleConstantValue).rawValue, true) + symbolStyleLayer.iconAllowsOverlap = MGLStyleConstantValue(rawValue: true) + XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleConstantValue).rawValue, true) // Number symbolStyleLayer.iconHaloWidth = MGLStyleConstantValue(rawValue: 3) @@ -32,7 +32,7 @@ extension MGLStyleValueTests { 3: MGLStyleValue(rawValue: true), 4: MGLStyleValue(rawValue: false), ] - symbolStyleLayer.iconAllowOverlap = MGLStyleFunction(base: 1, stops: stops) - XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleFunction), MGLStyleFunction(base: 1, stops: stops)) + symbolStyleLayer.iconAllowsOverlap = MGLStyleFunction(base: 1, stops: stops) + XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleFunction), MGLStyleFunction(base: 1, stops: stops)) } } diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.m b/platform/darwin/test/MGLSymbolStyleLayerTests.m index fc8d848a0a..40250a8c72 100644 --- a/platform/darwin/test/MGLSymbolStyleLayerTests.m +++ b/platform/darwin/test/MGLSymbolStyleLayerTests.m @@ -8,6 +8,10 @@ @implementation MGLSymbolLayerTests ++ (NSString *)layerType { + return @"symbol"; +} + - (void)testSymbolLayer { NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *url = [NSURL fileURLWithPath:filePath]; @@ -16,37 +20,37 @@ MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; [self.mapView.style addLayer:layer]; - layer.iconAllowOverlap = [MGLRuntimeStylingHelper testBool]; - layer.iconIgnorePlacement = [MGLRuntimeStylingHelper testBool]; + layer.iconAllowsOverlap = [MGLRuntimeStylingHelper testBool]; + layer.iconIgnoresPlacement = [MGLRuntimeStylingHelper testBool]; layer.iconImageName = [MGLRuntimeStylingHelper testString]; - layer.iconKeepUpright = [MGLRuntimeStylingHelper testBool]; layer.iconOffset = [MGLRuntimeStylingHelper testOffset]; layer.iconOptional = [MGLRuntimeStylingHelper testBool]; layer.iconPadding = [MGLRuntimeStylingHelper testNumber]; - layer.iconRotate = [MGLRuntimeStylingHelper testNumber]; + layer.iconRotation = [MGLRuntimeStylingHelper testNumber]; layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]; layer.iconScale = [MGLRuntimeStylingHelper testNumber]; layer.iconTextFit = [MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]; layer.iconTextFitPadding = [MGLRuntimeStylingHelper testPadding]; - layer.symbolAvoidEdges = [MGLRuntimeStylingHelper testBool]; + layer.keepsIconUpright = [MGLRuntimeStylingHelper testBool]; + layer.keepsTextUpright = [MGLRuntimeStylingHelper testBool]; + layer.maximumTextAngle = [MGLRuntimeStylingHelper testNumber]; + layer.maximumTextWidth = [MGLRuntimeStylingHelper testNumber]; + layer.symbolAvoidsEdges = [MGLRuntimeStylingHelper testBool]; layer.symbolPlacement = [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]; layer.symbolSpacing = [MGLRuntimeStylingHelper testNumber]; - layer.textAllowOverlap = [MGLRuntimeStylingHelper testBool]; + layer.textAllowsOverlap = [MGLRuntimeStylingHelper testBool]; layer.textAnchor = [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]; layer.textField = [MGLRuntimeStylingHelper testString]; layer.textFont = [MGLRuntimeStylingHelper testFont]; - layer.textIgnorePlacement = [MGLRuntimeStylingHelper testBool]; - layer.textJustify = [MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]; - layer.textKeepUpright = [MGLRuntimeStylingHelper testBool]; + layer.textIgnoresPlacement = [MGLRuntimeStylingHelper testBool]; + layer.textJustification = [MGLRuntimeStylingHelper testEnum:MGLTextJustificationRight type:@encode(MGLTextJustification)]; layer.textLetterSpacing = [MGLRuntimeStylingHelper testNumber]; layer.textLineHeight = [MGLRuntimeStylingHelper testNumber]; - layer.textMaxAngle = [MGLRuntimeStylingHelper testNumber]; - layer.textMaxWidth = [MGLRuntimeStylingHelper testNumber]; layer.textOffset = [MGLRuntimeStylingHelper testOffset]; layer.textOptional = [MGLRuntimeStylingHelper testBool]; layer.textPadding = [MGLRuntimeStylingHelper testNumber]; layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]; - layer.textRotate = [MGLRuntimeStylingHelper testNumber]; + layer.textRotation = [MGLRuntimeStylingHelper testNumber]; layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]; layer.textSize = [MGLRuntimeStylingHelper testNumber]; layer.textTransform = [MGLRuntimeStylingHelper testEnum:MGLTextTransformLowercase type:@encode(MGLTextTransform)]; @@ -67,43 +71,43 @@ MGLSymbolStyleLayer *gLayer = (MGLSymbolStyleLayer *)[self.mapView.style layerWithIdentifier:@"layerID"]; XCTAssertTrue([gLayer isKindOfClass:[MGLSymbolStyleLayer class]]); - XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBool]); - XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.iconAllowsOverlap, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.iconIgnoresPlacement, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconImageName, [MGLRuntimeStylingHelper testString]); - XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffset]); XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumber]); - XCTAssertEqualObjects(gLayer.iconRotate, [MGLRuntimeStylingHelper testNumber]); + XCTAssertEqualObjects(gLayer.iconRotation, [MGLRuntimeStylingHelper testNumber]); XCTAssert([gLayer.iconRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]); XCTAssertEqualObjects(gLayer.iconScale, [MGLRuntimeStylingHelper testNumber]); XCTAssert([gLayer.iconTextFit isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnum:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]); XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPadding]); - XCTAssertEqualObjects(gLayer.symbolAvoidEdges, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.keepsIconUpright, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.keepsTextUpright, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.maximumTextAngle, [MGLRuntimeStylingHelper testNumber]); + XCTAssertEqualObjects(gLayer.maximumTextWidth, [MGLRuntimeStylingHelper testNumber]); + XCTAssertEqualObjects(gLayer.symbolAvoidsEdges, [MGLRuntimeStylingHelper testBool]); XCTAssert([gLayer.symbolPlacement isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnum:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]); XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumber]); - XCTAssertEqualObjects(gLayer.textAllowOverlap, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.textAllowsOverlap, [MGLRuntimeStylingHelper testBool]); XCTAssert([gLayer.textAnchor isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]); XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testString]); XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFont]); - XCTAssertEqualObjects(gLayer.textIgnorePlacement, [MGLRuntimeStylingHelper testBool]); - XCTAssert([gLayer.textJustify isKindOfClass:[MGLStyleConstantValue class]]); - XCTAssertEqualObjects(gLayer.textJustify, [MGLRuntimeStylingHelper testEnum:MGLTextJustifyRight type:@encode(MGLTextJustify)]); - XCTAssertEqualObjects(gLayer.textKeepUpright, [MGLRuntimeStylingHelper testBool]); + XCTAssertEqualObjects(gLayer.textIgnoresPlacement, [MGLRuntimeStylingHelper testBool]); + XCTAssert([gLayer.textJustification isKindOfClass:[MGLStyleConstantValue class]]); + XCTAssertEqualObjects(gLayer.textJustification, [MGLRuntimeStylingHelper testEnum:MGLTextJustificationRight type:@encode(MGLTextJustification)]); XCTAssertEqualObjects(gLayer.textLetterSpacing, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textLineHeight, [MGLRuntimeStylingHelper testNumber]); - XCTAssertEqualObjects(gLayer.textMaxAngle, [MGLRuntimeStylingHelper testNumber]); - XCTAssertEqualObjects(gLayer.textMaxWidth, [MGLRuntimeStylingHelper testNumber]); XCTAssertEqualObjects(gLayer.textOffset, [MGLRuntimeStylingHelper testOffset]); XCTAssertEqualObjects(gLayer.textOptional, [MGLRuntimeStylingHelper testBool]); XCTAssertEqualObjects(gLayer.textPadding, [MGLRuntimeStylingHelper testNumber]); XCTAssert([gLayer.textPitchAlignment isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]); - XCTAssertEqualObjects(gLayer.textRotate, [MGLRuntimeStylingHelper testNumber]); + XCTAssertEqualObjects(gLayer.textRotation, [MGLRuntimeStylingHelper testNumber]); XCTAssert([gLayer.textRotationAlignment isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnum:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]); XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumber]); @@ -126,37 +130,37 @@ XCTAssert([gLayer.textTranslateAnchor isKindOfClass:[MGLStyleConstantValue class]]); XCTAssertEqualObjects(gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnum:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]); - layer.iconAllowOverlap = [MGLRuntimeStylingHelper testBoolFunction]; - layer.iconIgnorePlacement = [MGLRuntimeStylingHelper testBoolFunction]; + layer.iconAllowsOverlap = [MGLRuntimeStylingHelper testBoolFunction]; + layer.iconIgnoresPlacement = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconImageName = [MGLRuntimeStylingHelper testStringFunction]; - layer.iconKeepUpright = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconOffset = [MGLRuntimeStylingHelper testOffsetFunction]; layer.iconOptional = [MGLRuntimeStylingHelper testBoolFunction]; layer.iconPadding = [MGLRuntimeStylingHelper testNumberFunction]; - layer.iconRotate = [MGLRuntimeStylingHelper testNumberFunction]; + layer.iconRotation = [MGLRuntimeStylingHelper testNumberFunction]; layer.iconRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]; layer.iconScale = [MGLRuntimeStylingHelper testNumberFunction]; layer.iconTextFit = [MGLRuntimeStylingHelper testEnumFunction:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]; layer.iconTextFitPadding = [MGLRuntimeStylingHelper testPaddingFunction]; - layer.symbolAvoidEdges = [MGLRuntimeStylingHelper testBoolFunction]; + layer.keepsIconUpright = [MGLRuntimeStylingHelper testBoolFunction]; + layer.keepsTextUpright = [MGLRuntimeStylingHelper testBoolFunction]; + layer.maximumTextAngle = [MGLRuntimeStylingHelper testNumberFunction]; + layer.maximumTextWidth = [MGLRuntimeStylingHelper testNumberFunction]; + layer.symbolAvoidsEdges = [MGLRuntimeStylingHelper testBoolFunction]; layer.symbolPlacement = [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]; layer.symbolSpacing = [MGLRuntimeStylingHelper testNumberFunction]; - layer.textAllowOverlap = [MGLRuntimeStylingHelper testBoolFunction]; + layer.textAllowsOverlap = [MGLRuntimeStylingHelper testBoolFunction]; layer.textAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]; layer.textField = [MGLRuntimeStylingHelper testStringFunction]; layer.textFont = [MGLRuntimeStylingHelper testFontFunction]; - layer.textIgnorePlacement = [MGLRuntimeStylingHelper testBoolFunction]; - layer.textJustify = [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustifyRight type:@encode(MGLTextJustify)]; - layer.textKeepUpright = [MGLRuntimeStylingHelper testBoolFunction]; + layer.textIgnoresPlacement = [MGLRuntimeStylingHelper testBoolFunction]; + layer.textJustification = [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustificationRight type:@encode(MGLTextJustification)]; layer.textLetterSpacing = [MGLRuntimeStylingHelper testNumberFunction]; layer.textLineHeight = [MGLRuntimeStylingHelper testNumberFunction]; - layer.textMaxAngle = [MGLRuntimeStylingHelper testNumberFunction]; - layer.textMaxWidth = [MGLRuntimeStylingHelper testNumberFunction]; layer.textOffset = [MGLRuntimeStylingHelper testOffsetFunction]; layer.textOptional = [MGLRuntimeStylingHelper testBoolFunction]; layer.textPadding = [MGLRuntimeStylingHelper testNumberFunction]; layer.textPitchAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]; - layer.textRotate = [MGLRuntimeStylingHelper testNumberFunction]; + layer.textRotation = [MGLRuntimeStylingHelper testNumberFunction]; layer.textRotationAlignment = [MGLRuntimeStylingHelper testEnumFunction:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]; layer.textSize = [MGLRuntimeStylingHelper testNumberFunction]; layer.textTransform = [MGLRuntimeStylingHelper testEnumFunction:MGLTextTransformLowercase type:@encode(MGLTextTransform)]; @@ -175,37 +179,37 @@ layer.textTranslate = [MGLRuntimeStylingHelper testOffsetFunction]; layer.textTranslateAnchor = [MGLRuntimeStylingHelper testEnumFunction:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]; - XCTAssertEqualObjects(gLayer.iconAllowOverlap, [MGLRuntimeStylingHelper testBoolFunction]); - XCTAssertEqualObjects(gLayer.iconIgnorePlacement, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.iconAllowsOverlap, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.iconIgnoresPlacement, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconImageName, [MGLRuntimeStylingHelper testStringFunction]); - XCTAssertEqualObjects(gLayer.iconKeepUpright, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconOffset, [MGLRuntimeStylingHelper testOffsetFunction]); XCTAssertEqualObjects(gLayer.iconOptional, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.iconPadding, [MGLRuntimeStylingHelper testNumberFunction]); - XCTAssertEqualObjects(gLayer.iconRotate, [MGLRuntimeStylingHelper testNumberFunction]); + XCTAssertEqualObjects(gLayer.iconRotation, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.iconRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLIconRotationAlignmentAuto type:@encode(MGLIconRotationAlignment)]); XCTAssertEqualObjects(gLayer.iconScale, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.iconTextFit, [MGLRuntimeStylingHelper testEnumFunction:MGLIconTextFitBoth type:@encode(MGLIconTextFit)]); XCTAssertEqualObjects(gLayer.iconTextFitPadding, [MGLRuntimeStylingHelper testPaddingFunction]); - XCTAssertEqualObjects(gLayer.symbolAvoidEdges, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.keepsIconUpright, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.keepsTextUpright, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.maximumTextAngle, [MGLRuntimeStylingHelper testNumberFunction]); + XCTAssertEqualObjects(gLayer.maximumTextWidth, [MGLRuntimeStylingHelper testNumberFunction]); + XCTAssertEqualObjects(gLayer.symbolAvoidsEdges, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.symbolPlacement, [MGLRuntimeStylingHelper testEnumFunction:MGLSymbolPlacementLine type:@encode(MGLSymbolPlacement)]); XCTAssertEqualObjects(gLayer.symbolSpacing, [MGLRuntimeStylingHelper testNumberFunction]); - XCTAssertEqualObjects(gLayer.textAllowOverlap, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.textAllowsOverlap, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.textAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLTextAnchorBottomRight type:@encode(MGLTextAnchor)]); XCTAssertEqualObjects(gLayer.textField, [MGLRuntimeStylingHelper testStringFunction]); XCTAssertEqualObjects(gLayer.textFont, [MGLRuntimeStylingHelper testFontFunction]); - XCTAssertEqualObjects(gLayer.textIgnorePlacement, [MGLRuntimeStylingHelper testBoolFunction]); - XCTAssertEqualObjects(gLayer.textJustify, [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustifyRight type:@encode(MGLTextJustify)]); - XCTAssertEqualObjects(gLayer.textKeepUpright, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.textIgnoresPlacement, [MGLRuntimeStylingHelper testBoolFunction]); + XCTAssertEqualObjects(gLayer.textJustification, [MGLRuntimeStylingHelper testEnumFunction:MGLTextJustificationRight type:@encode(MGLTextJustification)]); XCTAssertEqualObjects(gLayer.textLetterSpacing, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textLineHeight, [MGLRuntimeStylingHelper testNumberFunction]); - XCTAssertEqualObjects(gLayer.textMaxAngle, [MGLRuntimeStylingHelper testNumberFunction]); - XCTAssertEqualObjects(gLayer.textMaxWidth, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textOffset, [MGLRuntimeStylingHelper testOffsetFunction]); XCTAssertEqualObjects(gLayer.textOptional, [MGLRuntimeStylingHelper testBoolFunction]); XCTAssertEqualObjects(gLayer.textPadding, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textPitchAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLTextPitchAlignmentAuto type:@encode(MGLTextPitchAlignment)]); - XCTAssertEqualObjects(gLayer.textRotate, [MGLRuntimeStylingHelper testNumberFunction]); + XCTAssertEqualObjects(gLayer.textRotation, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textRotationAlignment, [MGLRuntimeStylingHelper testEnumFunction:MGLTextRotationAlignmentAuto type:@encode(MGLTextRotationAlignment)]); XCTAssertEqualObjects(gLayer.textSize, [MGLRuntimeStylingHelper testNumberFunction]); XCTAssertEqualObjects(gLayer.textTransform, [MGLRuntimeStylingHelper testEnumFunction:MGLTextTransformLowercase type:@encode(MGLTextTransform)]); @@ -225,4 +229,55 @@ XCTAssertEqualObjects(gLayer.textTranslateAnchor, [MGLRuntimeStylingHelper testEnumFunction:MGLTextTranslateAnchorViewport type:@encode(MGLTextTranslateAnchor)]); } +- (void)testPropertyNames { + [self testPropertyName:@"icon-allows-overlap" isBoolean:YES]; + [self testPropertyName:@"icon-ignores-placement" isBoolean:YES]; + [self testPropertyName:@"icon-image-name" isBoolean:NO]; + [self testPropertyName:@"icon-offset" isBoolean:NO]; + [self testPropertyName:@"is-icon-optional" isBoolean:YES]; + [self testPropertyName:@"icon-padding" isBoolean:NO]; + [self testPropertyName:@"icon-rotation" isBoolean:NO]; + [self testPropertyName:@"icon-rotation-alignment" isBoolean:NO]; + [self testPropertyName:@"icon-scale" isBoolean:NO]; + [self testPropertyName:@"icon-text-fit" isBoolean:NO]; + [self testPropertyName:@"icon-text-fit-padding" isBoolean:NO]; + [self testPropertyName:@"keeps-icon-upright" isBoolean:YES]; + [self testPropertyName:@"keeps-text-upright" isBoolean:YES]; + [self testPropertyName:@"maximum-text-angle" isBoolean:NO]; + [self testPropertyName:@"maximum-text-width" isBoolean:NO]; + [self testPropertyName:@"symbol-avoids-edges" isBoolean:YES]; + [self testPropertyName:@"symbol-placement" isBoolean:NO]; + [self testPropertyName:@"symbol-spacing" isBoolean:NO]; + [self testPropertyName:@"text-allows-overlap" isBoolean:YES]; + [self testPropertyName:@"text-anchor" isBoolean:NO]; + [self testPropertyName:@"text-field" isBoolean:NO]; + [self testPropertyName:@"text-font" isBoolean:NO]; + [self testPropertyName:@"text-ignores-placement" isBoolean:YES]; + [self testPropertyName:@"text-justification" isBoolean:NO]; + [self testPropertyName:@"text-letter-spacing" isBoolean:NO]; + [self testPropertyName:@"text-line-height" isBoolean:NO]; + [self testPropertyName:@"text-offset" isBoolean:NO]; + [self testPropertyName:@"is-text-optional" isBoolean:YES]; + [self testPropertyName:@"text-padding" isBoolean:NO]; + [self testPropertyName:@"text-pitch-alignment" isBoolean:NO]; + [self testPropertyName:@"text-rotation" isBoolean:NO]; + [self testPropertyName:@"text-rotation-alignment" isBoolean:NO]; + [self testPropertyName:@"text-size" isBoolean:NO]; + [self testPropertyName:@"text-transform" isBoolean:NO]; + [self testPropertyName:@"icon-color" isBoolean:NO]; + [self testPropertyName:@"icon-halo-blur" isBoolean:NO]; + [self testPropertyName:@"icon-halo-color" isBoolean:NO]; + [self testPropertyName:@"icon-halo-width" isBoolean:NO]; + [self testPropertyName:@"icon-opacity" isBoolean:NO]; + [self testPropertyName:@"icon-translate" isBoolean:NO]; + [self testPropertyName:@"icon-translate-anchor" isBoolean:NO]; + [self testPropertyName:@"text-color" isBoolean:NO]; + [self testPropertyName:@"text-halo-blur" isBoolean:NO]; + [self testPropertyName:@"text-halo-color" isBoolean:NO]; + [self testPropertyName:@"text-halo-width" isBoolean:NO]; + [self testPropertyName:@"text-opacity" isBoolean:NO]; + [self testPropertyName:@"text-translate" isBoolean:NO]; + [self testPropertyName:@"text-translate-anchor" isBoolean:NO]; +} + @end diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 3a7f415f1f..05c2f91695 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -719,14 +719,14 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { }]; waterLayer.fillColor = waterColorFunction; - MGLStyleValue *fillAntialias = [MGLStyleValue valueWithStops:@{ + MGLStyleValue *fillAntialiasedFunction = [MGLStyleValue valueWithStops:@{ @11: [MGLStyleValue valueWithRawValue:@YES], @12: [MGLStyleValue valueWithRawValue:@NO], @13: [MGLStyleValue valueWithRawValue:@YES], @14: [MGLStyleValue valueWithRawValue:@NO], @15: [MGLStyleValue valueWithRawValue:@YES], }]; - waterLayer.fillAntialias = fillAntialias; + waterLayer.fillAntialiased = fillAntialiasedFunction; } - (void)styleRoadLayer diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 188492cc9d..c637cca7e8 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -759,7 +759,7 @@ DA8963341CC549A100684375 /* sprites */ = {isa = PBXFileReference; lastKnownFileType = folder; path = sprites; sourceTree = ""; }; DA8963351CC549A100684375 /* styles */ = {isa = PBXFileReference; lastKnownFileType = folder; path = styles; sourceTree = ""; }; DA8963361CC549A100684375 /* tiles */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tiles; sourceTree = ""; }; - DA8F25B91D51D2570010E6B5 /* MGLRuntimeStylingTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLRuntimeStylingTests.m.ejs; sourceTree = ""; }; + DA8F25B91D51D2570010E6B5 /* MGLStyleLayerTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; name = MGLStyleLayerTests.m.ejs; path = ../test/MGLStyleLayerTests.m.ejs; sourceTree = ""; }; DA8F25BA1D51D2570010E6B5 /* MGLStyleLayer.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.h.ejs; sourceTree = ""; }; DA8F25BB1D51D2570010E6B5 /* MGLStyleLayer.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.mm.ejs; sourceTree = ""; }; DAA4E4021CBB5C2F00178DFB /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -1246,9 +1246,9 @@ DA8F25BC1D51D2570010E6B5 /* Foundation Templates */ = { isa = PBXGroup; children = ( - DA8F25B91D51D2570010E6B5 /* MGLRuntimeStylingTests.m.ejs */, DA8F25BA1D51D2570010E6B5 /* MGLStyleLayer.h.ejs */, DA8F25BB1D51D2570010E6B5 /* MGLStyleLayer.mm.ejs */, + DA8F25B91D51D2570010E6B5 /* MGLStyleLayerTests.m.ejs */, 4032C5B71DE1EBB90062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */, 4032C5BC1DE1FAFC0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */, ); diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 9567efa6eb..5edb4429fb 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -376,7 +376,7 @@ DA8F259B1D51CB000010E6B5 /* MGLStyleValue_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleValue_Private.h; sourceTree = ""; }; DA8F25A61D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLStyleAttributeAdditions.h"; sourceTree = ""; }; DA8F25A71D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSValue+MGLStyleAttributeAdditions.mm"; sourceTree = ""; }; - DA8F25B51D51D2240010E6B5 /* MGLRuntimeStylingTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLRuntimeStylingTests.m.ejs; sourceTree = ""; }; + DA8F25B51D51D2240010E6B5 /* MGLStyleLayerTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; name = MGLStyleLayerTests.m.ejs; path = ../test/MGLStyleLayerTests.m.ejs; sourceTree = ""; }; DA8F25B61D51D2240010E6B5 /* MGLStyleLayer.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.h.ejs; sourceTree = ""; }; DA8F25B71D51D2240010E6B5 /* MGLStyleLayer.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.mm.ejs; sourceTree = ""; }; DAA48EFB1D6A4731006A7E36 /* StyleLayerIconTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleLayerIconTransformer.h; sourceTree = ""; }; @@ -715,11 +715,11 @@ DA8F25B81D51D2280010E6B5 /* Foundation Templates */ = { isa = PBXGroup; children = ( - 4032C5BA1DE1EECB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */, - 4032C5C71DE1FEAB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */, - DA8F25B51D51D2240010E6B5 /* MGLRuntimeStylingTests.m.ejs */, DA8F25B61D51D2240010E6B5 /* MGLStyleLayer.h.ejs */, DA8F25B71D51D2240010E6B5 /* MGLStyleLayer.mm.ejs */, + DA8F25B51D51D2240010E6B5 /* MGLStyleLayerTests.m.ejs */, + 4032C5BA1DE1EECB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.h.ejs */, + 4032C5C71DE1FEAB0062E8BD /* NSValue+MGLStyleEnumAttributeAdditions.mm.ejs */, ); name = "Foundation Templates"; path = ../../darwin/src; -- cgit v1.2.1