diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-12-16 08:09:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-16 08:09:42 -0800 |
commit | 3f26e88c49d3afeb3754a877b8473deb4bf2cded (patch) | |
tree | bc1dc3211623211302201d07219c46fdaf055487 | |
parent | b8466946e5eac5a4359206c19fe6e659ae9cf6c1 (diff) |
Use appropriate part of speech for properties (#7457)
* [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”).
29 files changed, 751 insertions, 243 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index de0e7d69a..9e79d0a32 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 a144871a6..49cf515e3 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 6a76f6072..f6a00de94 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 0cd84453a..266f2d836 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 9bbda26ce..cf8c18b5c 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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-fill-antialias"><code>fill-antialias</code></a> paint property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *fillAntialias; +@property (nonatomic, null_resettable, getter=isFillAntialiased) MGLStyleValue<NSNumber *> *fillAntialiased; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<MGLColor *> *fillOutlineColor; diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 47bd84fde..891ab85d0 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<NSNumber *> *)fillAntialias { +- (void)setFillAntialiased:(MGLStyleValue<NSNumber *> *)fillAntialiased { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(fillAntialias); + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(fillAntialiased); self.rawLayer->setFillAntialias(mbglValue); } -- (MGLStyleValue<NSNumber *> *)fillAntialias { +- (MGLStyleValue<NSNumber *> *)isFillAntialiased { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getFillAntialias() ?: self.rawLayer->getDefaultFillAntialias(); return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setFillAntialias:(MGLStyleValue<NSNumber *> *)fillAntialias { + NSAssert(NO, @"Use -setFillAntialiased: instead."); +} + - (void)setFillColor:(MGLStyleValue<MGLColor *> *)fillColor { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLLineStyleLayer.h b/platform/darwin/src/MGLLineStyleLayer.h index fce755527..c47c7d516 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<NSArray<NSNumber *> *> *lineDashPattern; + +@property (nonatomic, null_resettable) MGLStyleValue<NSArray<NSNumber *> *> *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 a23441c66..48164ed0c 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<std::vector<float>, NSArray<NSNumber *> *, float>().toStyleValue(propertyValue); } + +- (void)setLineDasharray:(MGLStyleValue<NSArray<NSNumber *> *> *)lineDasharray { + NSAssert(NO, @"Use -setLineDashPattern: instead."); +} + - (void)setLineGapWidth:(MGLStyleValue<NSNumber *> *)lineGapWidth { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLRasterStyleLayer.h b/platform/darwin/src/MGLRasterStyleLayer.h index 916a0128d..def5221d6 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<NSNumber *> *maximumRasterBrightness; + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<NSNumber *> *minimumRasterBrightness; + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<NSNumber *> *rasterHueRotation; + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 9c2a64d0d..e61532773 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<float, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setRasterBrightnessMax:(MGLStyleValue<NSNumber *> *)rasterBrightnessMax { + NSAssert(NO, @"Use -setMaximumRasterBrightness: instead."); +} + - (void)setMinimumRasterBrightness:(MGLStyleValue<NSNumber *> *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); @@ -110,6 +115,11 @@ return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setRasterBrightnessMin:(MGLStyleValue<NSNumber *> *)rasterBrightnessMin { + NSAssert(NO, @"Use -setMinimumRasterBrightness: instead."); +} + - (void)setRasterContrast:(MGLStyleValue<NSNumber *> *)rasterContrast { MGLAssertStyleLayerIsValid(); @@ -152,6 +162,11 @@ return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setRasterHueRotate:(MGLStyleValue<NSNumber *> *)rasterHueRotate { + NSAssert(NO, @"Use -setRasterHueRotation: instead."); +} + - (void)setRasterOpacity:(MGLStyleValue<NSNumber *> *)rasterOpacity { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/MGLStyleLayer.h.ejs b/platform/darwin/src/MGLStyleLayer.h.ejs index d454ec0c6..3b576e766 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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-<%- type -%>-<%- property.original -%>"><code><%- property.original -%></code></a> 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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#paint-<%- property.original -%>"><code><%- property.original -%></code></a> 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 3b446dd02..6178eaad5 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<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, 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<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, 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<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); + auto mbglValue = MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, 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<mbgl::style::<%- mbglType(property) %>, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<mbgl::style::<%- mbglType(property) %>, 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 621339db7..5a216e035 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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-allow-overlap"><code>icon-allow-overlap</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconAllowOverlap; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconAllowsOverlap; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-ignore-placement"><code>icon-ignore-placement</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconIgnorePlacement; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconIgnoresPlacement; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<NSString *> *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<NSNumber *> *iconKeepUpright; + +@property (nonatomic, null_resettable) MGLStyleValue<NSString *> *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<NSNumber *> *iconOptional; +@property (nonatomic, null_resettable, getter=isIconOptional) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-rotate"><code>icon-rotate</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconRotate; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconRotation; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<NSNumber *> *iconScale; + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *iconSize __attribute__((unavailable("Use iconScale instead."))); + /** Scales the icon to fit around the associated text. @@ -347,11 +359,76 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { @property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-icon-keep-upright"><code>icon-keep-upright</code></a> layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *keepsIconUpright; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-keep-upright"><code>text-keep-upright</code></a> layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *keepsTextUpright; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-max-angle"><code>text-max-angle</code></a> layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *maximumTextAngle; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-max-width"><code>text-max-width</code></a> layout property in the Mapbox Style Specification. + */ +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *maximumTextWidth; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-symbol-avoid-edges"><code>symbol-avoid-edges</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *symbolAvoidEdges; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *symbolAvoidsEdges; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-allow-overlap"><code>text-allow-overlap</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textAllowOverlap; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textAllowsOverlap; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-ignore-placement"><code>text-ignore-placement</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textIgnorePlacement; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textIgnoresPlacement; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<NSValue *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-justify"><code>text-justify</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textKeepUpright; +@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textJustification; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSValue *> *textJustify __attribute__((unavailable("Use textJustification instead."))); /** Text tracking amount. @@ -455,28 +538,6 @@ typedef NS_ENUM(NSUInteger, MGLTextTranslateAnchor) { @property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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<NSNumber *> *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<NSNumber *> *textMaxWidth; - -/** Offset distance of text from its anchor. This property is measured in ems. @@ -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<NSNumber *> *textOptional; +@property (nonatomic, null_resettable, getter=isTextOptional) MGLStyleValue<NSNumber *> *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 <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-rotate"><code>text-rotate</code></a> layout property in the Mapbox Style Specification. */ -@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textRotate; +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *textRotation; + + +@property (nonatomic, null_resettable) MGLStyleValue<NSNumber *> *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 af92c6ba6..31c584b47 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<NSNumber *> *)iconAllowOverlap { +- (void)setIconAllowsOverlap:(MGLStyleValue<NSNumber *> *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconAllowOverlap); + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconAllowsOverlap); self.rawLayer->setIconAllowOverlap(mbglValue); } -- (MGLStyleValue<NSNumber *> *)iconAllowOverlap { +- (MGLStyleValue<NSNumber *> *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconAllowOverlap() ?: self.rawLayer->getDefaultIconAllowOverlap(); return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); } -- (void)setIconIgnorePlacement:(MGLStyleValue<NSNumber *> *)iconIgnorePlacement { + +- (void)setIconAllowOverlap:(MGLStyleValue<NSNumber *> *)iconAllowOverlap { + self.iconAllowsOverlap = iconAllowOverlap; +} + +- (MGLStyleValue<NSNumber *> *)iconAllowOverlap { + return self.iconAllowsOverlap; +} + +- (void)setIconIgnoresPlacement:(MGLStyleValue<NSNumber *> *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconIgnorePlacement); + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconIgnoresPlacement); self.rawLayer->setIconIgnorePlacement(mbglValue); } -- (MGLStyleValue<NSNumber *> *)iconIgnorePlacement { +- (MGLStyleValue<NSNumber *> *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconIgnorePlacement() ?: self.rawLayer->getDefaultIconIgnorePlacement(); return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setIconIgnorePlacement:(MGLStyleValue<NSNumber *> *)iconIgnorePlacement { + self.iconIgnoresPlacement = iconIgnorePlacement; +} + +- (MGLStyleValue<NSNumber *> *)iconIgnorePlacement { + return self.iconIgnoresPlacement; +} + - (void)setIconImageName:(MGLStyleValue<NSString *> *)iconImageName { MGLAssertStyleLayerIsValid(); @@ -220,18 +238,13 @@ namespace mbgl { return MGLStyleValueTransformer<std::string, NSString *>().toStyleValue(propertyValue); } -- (void)setIconKeepUpright:(MGLStyleValue<NSNumber *> *)iconKeepUpright { - MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(iconKeepUpright); - self.rawLayer->setIconKeepUpright(mbglValue); +- (void)setIconImage:(MGLStyleValue<NSString *> *)iconImage { + self.iconImageName = iconImage; } -- (MGLStyleValue<NSNumber *> *)iconKeepUpright { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright(); - return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); +- (MGLStyleValue<NSString *> *)iconImage { + return self.iconImageName; } - (void)setIconOffset:(MGLStyleValue<NSValue *> *)iconOffset { @@ -255,7 +268,7 @@ namespace mbgl { self.rawLayer->setIconOptional(mbglValue); } -- (MGLStyleValue<NSNumber *> *)iconOptional { +- (MGLStyleValue<NSNumber *> *)isIconOptional { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconOptional() ?: self.rawLayer->getDefaultIconOptional(); @@ -276,20 +289,29 @@ namespace mbgl { return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } -- (void)setIconRotate:(MGLStyleValue<NSNumber *> *)iconRotate { +- (void)setIconRotation:(MGLStyleValue<NSNumber *> *)iconRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconRotate); + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(iconRotation); self.rawLayer->setIconRotate(mbglValue); } -- (MGLStyleValue<NSNumber *> *)iconRotate { +- (MGLStyleValue<NSNumber *> *)iconRotation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getIconRotate() ?: self.rawLayer->getDefaultIconRotate(); return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setIconRotate:(MGLStyleValue<NSNumber *> *)iconRotate { + self.iconRotation = iconRotate; +} + +- (MGLStyleValue<NSNumber *> *)iconRotate { + return self.iconRotation; +} + - (void)setIconRotationAlignment:(MGLStyleValue<NSValue *> *)iconRotationAlignment { MGLAssertStyleLayerIsValid(); @@ -318,6 +340,15 @@ namespace mbgl { return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setIconSize:(MGLStyleValue<NSNumber *> *)iconSize { + self.iconScale = iconSize; +} + +- (MGLStyleValue<NSNumber *> *)iconSize { + return self.iconScale; +} + - (void)setIconTextFit:(MGLStyleValue<NSValue *> *)iconTextFit { MGLAssertStyleLayerIsValid(); @@ -346,20 +377,121 @@ namespace mbgl { return MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toStyleValue(propertyValue); } -- (void)setSymbolAvoidEdges:(MGLStyleValue<NSNumber *> *)symbolAvoidEdges { +- (void)setKeepsIconUpright:(MGLStyleValue<NSNumber *> *)keepsIconUpright { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(keepsIconUpright); + self.rawLayer->setIconKeepUpright(mbglValue); +} + +- (MGLStyleValue<NSNumber *> *)keepsIconUpright { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright(); + return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); +} + + +- (void)setIconKeepUpright:(MGLStyleValue<NSNumber *> *)iconKeepUpright { + self.keepsIconUpright = iconKeepUpright; +} + +- (MGLStyleValue<NSNumber *> *)iconKeepUpright { + return self.keepsIconUpright; +} + +- (void)setKeepsTextUpright:(MGLStyleValue<NSNumber *> *)keepsTextUpright { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(keepsTextUpright); + self.rawLayer->setTextKeepUpright(mbglValue); +} + +- (MGLStyleValue<NSNumber *> *)keepsTextUpright { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright(); + return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); +} + + +- (void)setTextKeepUpright:(MGLStyleValue<NSNumber *> *)textKeepUpright { + self.keepsTextUpright = textKeepUpright; +} + +- (MGLStyleValue<NSNumber *> *)textKeepUpright { + return self.keepsTextUpright; +} + +- (void)setMaximumTextAngle:(MGLStyleValue<NSNumber *> *)maximumTextAngle { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(maximumTextAngle); + self.rawLayer->setTextMaxAngle(mbglValue); +} + +- (MGLStyleValue<NSNumber *> *)maximumTextAngle { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle(); + return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); +} + + +- (void)setTextMaxAngle:(MGLStyleValue<NSNumber *> *)textMaxAngle { + self.maximumTextAngle = textMaxAngle; +} + +- (MGLStyleValue<NSNumber *> *)textMaxAngle { + return self.maximumTextAngle; +} + +- (void)setMaximumTextWidth:(MGLStyleValue<NSNumber *> *)maximumTextWidth { + MGLAssertStyleLayerIsValid(); + + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(maximumTextWidth); + self.rawLayer->setTextMaxWidth(mbglValue); +} + +- (MGLStyleValue<NSNumber *> *)maximumTextWidth { + MGLAssertStyleLayerIsValid(); + + auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth(); + return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); +} + + +- (void)setTextMaxWidth:(MGLStyleValue<NSNumber *> *)textMaxWidth { + self.maximumTextWidth = textMaxWidth; +} + +- (MGLStyleValue<NSNumber *> *)textMaxWidth { + return self.maximumTextWidth; +} + +- (void)setSymbolAvoidsEdges:(MGLStyleValue<NSNumber *> *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(symbolAvoidEdges); + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(symbolAvoidsEdges); self.rawLayer->setSymbolAvoidEdges(mbglValue); } -- (MGLStyleValue<NSNumber *> *)symbolAvoidEdges { +- (MGLStyleValue<NSNumber *> *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getSymbolAvoidEdges() ?: self.rawLayer->getDefaultSymbolAvoidEdges(); return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setSymbolAvoidEdges:(MGLStyleValue<NSNumber *> *)symbolAvoidEdges { + self.symbolAvoidsEdges = symbolAvoidEdges; +} + +- (MGLStyleValue<NSNumber *> *)symbolAvoidEdges { + return self.symbolAvoidsEdges; +} + - (void)setSymbolPlacement:(MGLStyleValue<NSValue *> *)symbolPlacement { MGLAssertStyleLayerIsValid(); @@ -388,20 +520,29 @@ namespace mbgl { return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } -- (void)setTextAllowOverlap:(MGLStyleValue<NSNumber *> *)textAllowOverlap { +- (void)setTextAllowsOverlap:(MGLStyleValue<NSNumber *> *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textAllowOverlap); + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textAllowsOverlap); self.rawLayer->setTextAllowOverlap(mbglValue); } -- (MGLStyleValue<NSNumber *> *)textAllowOverlap { +- (MGLStyleValue<NSNumber *> *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextAllowOverlap() ?: self.rawLayer->getDefaultTextAllowOverlap(); return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setTextAllowOverlap:(MGLStyleValue<NSNumber *> *)textAllowOverlap { + self.textAllowsOverlap = textAllowOverlap; +} + +- (MGLStyleValue<NSNumber *> *)textAllowOverlap { + return self.textAllowsOverlap; +} + - (void)setTextAnchor:(MGLStyleValue<NSValue *> *)textAnchor { MGLAssertStyleLayerIsValid(); @@ -444,46 +585,50 @@ namespace mbgl { return MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toStyleValue(propertyValue); } -- (void)setTextIgnorePlacement:(MGLStyleValue<NSNumber *> *)textIgnorePlacement { +- (void)setTextIgnoresPlacement:(MGLStyleValue<NSNumber *> *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textIgnorePlacement); + auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textIgnoresPlacement); self.rawLayer->setTextIgnorePlacement(mbglValue); } -- (MGLStyleValue<NSNumber *> *)textIgnorePlacement { +- (MGLStyleValue<NSNumber *> *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextIgnorePlacement() ?: self.rawLayer->getDefaultTextIgnorePlacement(); return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); } -- (void)setTextJustify:(MGLStyleValue<NSValue *> *)textJustify { + +- (void)setTextIgnorePlacement:(MGLStyleValue<NSNumber *> *)textIgnorePlacement { + self.textIgnoresPlacement = textIgnorePlacement; +} + +- (MGLStyleValue<NSNumber *> *)textIgnorePlacement { + return self.textIgnoresPlacement; +} + +- (void)setTextJustification:(MGLStyleValue<NSValue *> *)textJustification { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustify>().toEnumPropertyValue(textJustify); + auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumPropertyValue(textJustification); self.rawLayer->setTextJustify(mbglValue); } -- (MGLStyleValue<NSValue *> *)textJustify { +- (MGLStyleValue<NSValue *> *)textJustification { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextJustify() ?: self.rawLayer->getDefaultTextJustify(); - return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustify>().toEnumStyleValue(propertyValue); + return MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toEnumStyleValue(propertyValue); } -- (void)setTextKeepUpright:(MGLStyleValue<NSNumber *> *)textKeepUpright { - MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue(textKeepUpright); - self.rawLayer->setTextKeepUpright(mbglValue); +- (void)setTextJustify:(MGLStyleValue<NSValue *> *)textJustify { + self.textJustification = textJustify; } -- (MGLStyleValue<NSNumber *> *)textKeepUpright { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright(); - return MGLStyleValueTransformer<bool, NSNumber *>().toStyleValue(propertyValue); +- (MGLStyleValue<NSValue *> *)textJustify { + return self.textJustification; } - (void)setTextLetterSpacing:(MGLStyleValue<NSNumber *> *)textLetterSpacing { @@ -514,34 +659,6 @@ namespace mbgl { return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } -- (void)setTextMaxAngle:(MGLStyleValue<NSNumber *> *)textMaxAngle { - MGLAssertStyleLayerIsValid(); - - auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textMaxAngle); - self.rawLayer->setTextMaxAngle(mbglValue); -} - -- (MGLStyleValue<NSNumber *> *)textMaxAngle { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle(); - return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); -} - -- (void)setTextMaxWidth:(MGLStyleValue<NSNumber *> *)textMaxWidth { - MGLAssertStyleLayerIsValid(); - - auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textMaxWidth); - self.rawLayer->setTextMaxWidth(mbglValue); -} - -- (MGLStyleValue<NSNumber *> *)textMaxWidth { - MGLAssertStyleLayerIsValid(); - - auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth(); - return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); -} - - (void)setTextOffset:(MGLStyleValue<NSValue *> *)textOffset { MGLAssertStyleLayerIsValid(); @@ -563,7 +680,7 @@ namespace mbgl { self.rawLayer->setTextOptional(mbglValue); } -- (MGLStyleValue<NSNumber *> *)textOptional { +- (MGLStyleValue<NSNumber *> *)isTextOptional { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextOptional() ?: self.rawLayer->getDefaultTextOptional(); @@ -598,20 +715,29 @@ namespace mbgl { return MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toEnumStyleValue(propertyValue); } -- (void)setTextRotate:(MGLStyleValue<NSNumber *> *)textRotate { +- (void)setTextRotation:(MGLStyleValue<NSNumber *> *)textRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textRotate); + auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue(textRotation); self.rawLayer->setTextRotate(mbglValue); } -- (MGLStyleValue<NSNumber *> *)textRotate { +- (MGLStyleValue<NSNumber *> *)textRotation { MGLAssertStyleLayerIsValid(); auto propertyValue = self.rawLayer->getTextRotate() ?: self.rawLayer->getDefaultTextRotate(); return MGLStyleValueTransformer<float, NSNumber *>().toStyleValue(propertyValue); } + +- (void)setTextRotate:(MGLStyleValue<NSNumber *> *)textRotate { + self.textRotation = textRotate; +} + +- (MGLStyleValue<NSNumber *> *)textRotate { + return self.textRotation; +} + - (void)setTextRotationAlignment:(MGLStyleValue<NSValue *> *)textRotationAlignment { MGLAssertStyleLayerIsValid(); diff --git a/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h b/platform/darwin/src/NSValue+MGLStyleEnumAttributeAdditions.h index 8aa07b2a0..3387ce818 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 89f0c07a5..db91408c5 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 09bed7665..934021d6b 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 f98e73135..66c05f15c 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 dd16214a7..7d51c15cf 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 49dd1f219..e877c1d57 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 485664c98..f8de191da 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 f81e075e0..74ce62e89 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 74c6b2f90..590d6eda7 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/src/MGLRuntimeStylingTests.m.ejs b/platform/darwin/test/MGLStyleLayerTests.m.ejs index 91c626d1a..6b7bfe2f1 100644 --- a/platform/darwin/src/MGLRuntimeStylingTests.m.ejs +++ b/platform/darwin/test/MGLStyleLayerTests.m.ejs @@ -13,6 +13,10 @@ @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"]; @@ -56,4 +60,13 @@ <% } -%> } +- (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 e529af063..bf0143511 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<NSNumber>).rawValue, true) + symbolStyleLayer.iconAllowsOverlap = MGLStyleConstantValue(rawValue: true) + XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleConstantValue<NSNumber>).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<NSNumber>(base: 1, stops: stops) - XCTAssertEqual((symbolStyleLayer.iconAllowOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(base: 1, stops: stops)) + symbolStyleLayer.iconAllowsOverlap = MGLStyleFunction<NSNumber>(base: 1, stops: stops) + XCTAssertEqual((symbolStyleLayer.iconAllowsOverlap as! MGLStyleFunction<NSNumber>), MGLStyleFunction(base: 1, stops: stops)) } } diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.m b/platform/darwin/test/MGLSymbolStyleLayerTests.m index fc8d848a0..40250a8c7 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 3a7f415f1..05c2f9169 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<NSNumber *> valueWithStops:@{ + MGLStyleValue *fillAntialiasedFunction = [MGLStyleValue<NSNumber *> valueWithStops:@{ @11: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES], @12: [MGLStyleValue<NSNumber *> valueWithRawValue:@NO], @13: [MGLStyleValue<NSNumber *> valueWithRawValue:@YES], @14: [MGLStyleValue<NSNumber *> valueWithRawValue:@NO], @15: [MGLStyleValue<NSNumber *> 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 188492cc9..c637cca7e 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 = "<group>"; }; DA8963351CC549A100684375 /* styles */ = {isa = PBXFileReference; lastKnownFileType = folder; path = styles; sourceTree = "<group>"; }; DA8963361CC549A100684375 /* tiles */ = {isa = PBXFileReference; lastKnownFileType = folder; path = tiles; sourceTree = "<group>"; }; - DA8F25B91D51D2570010E6B5 /* MGLRuntimeStylingTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLRuntimeStylingTests.m.ejs; sourceTree = "<group>"; }; + DA8F25B91D51D2570010E6B5 /* MGLStyleLayerTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; name = MGLStyleLayerTests.m.ejs; path = ../test/MGLStyleLayerTests.m.ejs; sourceTree = "<group>"; }; DA8F25BA1D51D2570010E6B5 /* MGLStyleLayer.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.h.ejs; sourceTree = "<group>"; }; DA8F25BB1D51D2570010E6B5 /* MGLStyleLayer.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.mm.ejs; sourceTree = "<group>"; }; 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 9567efa6e..5edb4429f 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 = "<group>"; }; DA8F25A61D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSValue+MGLStyleAttributeAdditions.h"; sourceTree = "<group>"; }; DA8F25A71D51CB270010E6B5 /* NSValue+MGLStyleAttributeAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSValue+MGLStyleAttributeAdditions.mm"; sourceTree = "<group>"; }; - DA8F25B51D51D2240010E6B5 /* MGLRuntimeStylingTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLRuntimeStylingTests.m.ejs; sourceTree = "<group>"; }; + DA8F25B51D51D2240010E6B5 /* MGLStyleLayerTests.m.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; name = MGLStyleLayerTests.m.ejs; path = ../test/MGLStyleLayerTests.m.ejs; sourceTree = "<group>"; }; DA8F25B61D51D2240010E6B5 /* MGLStyleLayer.h.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.h.ejs; sourceTree = "<group>"; }; DA8F25B71D51D2240010E6B5 /* MGLStyleLayer.mm.ejs */ = {isa = PBXFileReference; lastKnownFileType = text; path = MGLStyleLayer.mm.ejs; sourceTree = "<group>"; }; DAA48EFB1D6A4731006A7E36 /* StyleLayerIconTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleLayerIconTransformer.h; sourceTree = "<group>"; }; @@ -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; |