diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index e7041ad9f3c..6606c956f2d 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -8,10 +8,16 @@ const colorParser = require('csscolorparser'); require('../../../scripts/style-code'); const cocoaConventions = require('./style-spec-cocoa-conventions-v8.json'); -let spec = _.merge(require('mapbox-gl-style-spec').latest, require('./style-spec-overrides-v8.json')); const prefix = 'MGL'; const suffix = 'StyleLayer'; +let spec = _.merge(require('mapbox-gl-style-spec').latest, require('./style-spec-overrides-v8.json')); + +/// +// Temporarily IGNORE layers that are in the spec yet still not supported in mbgl core +/// +delete spec.layer.type.values['fill-extrusion']; + // Rename properties and keep `original` for use with setters and getters _.forOwn(cocoaConventions, function (properties, kind) { _.forOwn(properties, function (newName, oldName) { diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index f6a00de9419..ad94917585e 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -92,7 +92,10 @@ - (void)setBackgroundColor:(MGLStyleValue *)backgroundColor { - (MGLStyleValue *)backgroundColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getBackgroundColor() ?: self.rawLayer->getDefaultBackgroundColor(); + auto propertyValue = self.rawLayer->getBackgroundColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultBackgroundColor()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -106,7 +109,10 @@ - (void)setBackgroundOpacity:(MGLStyleValue *)backgroundOpacity { - (MGLStyleValue *)backgroundOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getBackgroundOpacity() ?: self.rawLayer->getDefaultBackgroundOpacity(); + auto propertyValue = self.rawLayer->getBackgroundOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultBackgroundOpacity()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -120,9 +126,12 @@ - (void)setBackgroundPattern:(MGLStyleValue *)backgroundPattern { - (MGLStyleValue *)backgroundPattern { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getBackgroundPattern() ?: self.rawLayer->getDefaultBackgroundPattern(); + auto propertyValue = self.rawLayer->getBackgroundPattern(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultBackgroundPattern()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } -@end +@end \ No newline at end of file diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index e8ee2bca7e6..d09654ad63f 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -127,43 +127,52 @@ - (void)removeFromMapView:(MGLMapView *)mapView - (void)setCircleBlur:(MGLStyleValue *)circleBlur { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleBlur); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleBlur); self.rawLayer->setCircleBlur(mbglValue); } - (MGLStyleValue *)circleBlur { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleBlur() ?: self.rawLayer->getDefaultCircleBlur(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleBlur(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleBlur()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCircleColor:(MGLStyleValue *)circleColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleColor); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleColor); self.rawLayer->setCircleColor(mbglValue); } - (MGLStyleValue *)circleColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleColor() ?: self.rawLayer->getDefaultCircleColor(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleColor()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCircleOpacity:(MGLStyleValue *)circleOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleOpacity); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleOpacity); self.rawLayer->setCircleOpacity(mbglValue); } - (MGLStyleValue *)circleOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleOpacity() ?: self.rawLayer->getDefaultCircleOpacity(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleOpacity()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { @@ -171,69 +180,85 @@ - (void)setCirclePitchScale:(MGLStyleValue *)circlePitchScale { auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(circlePitchScale); self.rawLayer->setCirclePitchScale(mbglValue); + self.rawLayer->setCirclePitchScale(mbglValue); } - (MGLStyleValue *)circlePitchScale { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCirclePitchScale() ?: self.rawLayer->getDefaultCirclePitchScale(); + auto propertyValue = self.rawLayer->getCirclePitchScale(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultCirclePitchScale()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } - (void)setCircleRadius:(MGLStyleValue *)circleRadius { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleRadius); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleRadius); self.rawLayer->setCircleRadius(mbglValue); } - (MGLStyleValue *)circleRadius { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleRadius() ?: self.rawLayer->getDefaultCircleRadius(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleRadius(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleRadius()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCircleStrokeColor:(MGLStyleValue *)circleStrokeColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleStrokeColor); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleStrokeColor); self.rawLayer->setCircleStrokeColor(mbglValue); } - (MGLStyleValue *)circleStrokeColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleStrokeColor() ?: self.rawLayer->getDefaultCircleStrokeColor(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleStrokeColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleStrokeColor()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCircleStrokeOpacity:(MGLStyleValue *)circleStrokeOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleStrokeOpacity); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleStrokeOpacity); self.rawLayer->setCircleStrokeOpacity(mbglValue); } - (MGLStyleValue *)circleStrokeOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleStrokeOpacity() ?: self.rawLayer->getDefaultCircleStrokeOpacity(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleStrokeOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleStrokeOpacity()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCircleStrokeWidth:(MGLStyleValue *)circleStrokeWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(circleStrokeWidth); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(circleStrokeWidth); self.rawLayer->setCircleStrokeWidth(mbglValue); } - (MGLStyleValue *)circleStrokeWidth { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleStrokeWidth() ?: self.rawLayer->getDefaultCircleStrokeWidth(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getCircleStrokeWidth(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultCircleStrokeWidth()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setCircleTranslate:(MGLStyleValue *)circleTranslate { @@ -246,7 +271,10 @@ - (void)setCircleTranslate:(MGLStyleValue *)circleTranslate { - (MGLStyleValue *)circleTranslate { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleTranslate() ?: self.rawLayer->getDefaultCircleTranslate(); + auto propertyValue = self.rawLayer->getCircleTranslate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultCircleTranslate()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -255,14 +283,18 @@ - (void)setCircleTranslateAnchor:(MGLStyleValue *)circleTranslateAnch auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(circleTranslateAnchor); self.rawLayer->setCircleTranslateAnchor(mbglValue); + self.rawLayer->setCircleTranslateAnchor(mbglValue); } - (MGLStyleValue *)circleTranslateAnchor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getCircleTranslateAnchor() ?: self.rawLayer->getDefaultCircleTranslateAnchor(); + auto propertyValue = self.rawLayer->getCircleTranslateAnchor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultCircleTranslateAnchor()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -@end +@end \ No newline at end of file diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index 891ab85d0b8..2fbda9fb433 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -129,7 +129,10 @@ - (void)setFillAntialiased:(MGLStyleValue *)fillAntialiased { - (MGLStyleValue *)isFillAntialiased { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillAntialias() ?: self.rawLayer->getDefaultFillAntialias(); + auto propertyValue = self.rawLayer->getFillAntialias(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultFillAntialias()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -141,43 +144,52 @@ - (void)setFillAntialias:(MGLStyleValue *)fillAntialias { - (void)setFillColor:(MGLStyleValue *)fillColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillColor); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(fillColor); self.rawLayer->setFillColor(mbglValue); } - (MGLStyleValue *)fillColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillColor() ?: self.rawLayer->getDefaultFillColor(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getFillColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultFillColor()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setFillOpacity:(MGLStyleValue *)fillOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOpacity); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(fillOpacity); self.rawLayer->setFillOpacity(mbglValue); } - (MGLStyleValue *)fillOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillOpacity() ?: self.rawLayer->getDefaultFillOpacity(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getFillOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultFillOpacity()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setFillOutlineColor:(MGLStyleValue *)fillOutlineColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(fillOutlineColor); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(fillOutlineColor); self.rawLayer->setFillOutlineColor(mbglValue); } - (MGLStyleValue *)fillOutlineColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillOutlineColor() ?: self.rawLayer->getDefaultFillOutlineColor(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getFillOutlineColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultFillOutlineColor()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setFillPattern:(MGLStyleValue *)fillPattern { @@ -190,7 +202,10 @@ - (void)setFillPattern:(MGLStyleValue *)fillPattern { - (MGLStyleValue *)fillPattern { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillPattern() ?: self.rawLayer->getDefaultFillPattern(); + auto propertyValue = self.rawLayer->getFillPattern(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultFillPattern()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -204,7 +219,10 @@ - (void)setFillTranslate:(MGLStyleValue *)fillTranslate { - (MGLStyleValue *)fillTranslate { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillTranslate() ?: self.rawLayer->getDefaultFillTranslate(); + auto propertyValue = self.rawLayer->getFillTranslate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultFillTranslate()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -213,14 +231,18 @@ - (void)setFillTranslateAnchor:(MGLStyleValue *)fillTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(fillTranslateAnchor); self.rawLayer->setFillTranslateAnchor(mbglValue); + self.rawLayer->setFillTranslateAnchor(mbglValue); } - (MGLStyleValue *)fillTranslateAnchor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getFillTranslateAnchor() ?: self.rawLayer->getDefaultFillTranslateAnchor(); + auto propertyValue = self.rawLayer->getFillTranslateAnchor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultFillTranslateAnchor()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -@end +@end \ No newline at end of file diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 48164ed0c83..2305ccbf5b3 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -141,7 +141,10 @@ - (void)setLineCap:(MGLStyleValue *)lineCap { - (MGLStyleValue *)lineCap { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineCap() ?: self.rawLayer->getDefaultLineCap(); + auto propertyValue = self.rawLayer->getLineCap(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultLineCap()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -155,7 +158,10 @@ - (void)setLineJoin:(MGLStyleValue *)lineJoin { - (MGLStyleValue *)lineJoin { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineJoin() ?: self.rawLayer->getDefaultLineJoin(); + auto propertyValue = self.rawLayer->getLineJoin(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultLineJoin()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -169,7 +175,10 @@ - (void)setLineMiterLimit:(MGLStyleValue *)lineMiterLimit { - (MGLStyleValue *)lineMiterLimit { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineMiterLimit() ?: self.rawLayer->getDefaultLineMiterLimit(); + auto propertyValue = self.rawLayer->getLineMiterLimit(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultLineMiterLimit()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -183,7 +192,10 @@ - (void)setLineRoundLimit:(MGLStyleValue *)lineRoundLimit { - (MGLStyleValue *)lineRoundLimit { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineRoundLimit() ?: self.rawLayer->getDefaultLineRoundLimit(); + auto propertyValue = self.rawLayer->getLineRoundLimit(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultLineRoundLimit()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -192,29 +204,35 @@ - (void)setLineRoundLimit:(MGLStyleValue *)lineRoundLimit { - (void)setLineBlur:(MGLStyleValue *)lineBlur { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineBlur); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(lineBlur); self.rawLayer->setLineBlur(mbglValue); } - (MGLStyleValue *)lineBlur { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineBlur() ?: self.rawLayer->getDefaultLineBlur(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getLineBlur(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultLineBlur()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setLineColor:(MGLStyleValue *)lineColor { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineColor); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(lineColor); self.rawLayer->setLineColor(mbglValue); } - (MGLStyleValue *)lineColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineColor() ?: self.rawLayer->getDefaultLineColor(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getLineColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultLineColor()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setLineDashPattern:(MGLStyleValue *> *)lineDashPattern { @@ -227,7 +245,10 @@ - (void)setLineDashPattern:(MGLStyleValue *> *)lineDashPatte - (MGLStyleValue *> *)lineDashPattern { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineDasharray() ?: self.rawLayer->getDefaultLineDasharray(); + auto propertyValue = self.rawLayer->getLineDasharray(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(self.rawLayer->getDefaultLineDasharray()); + } return MGLStyleValueTransformer, NSArray *, float>().toStyleValue(propertyValue); } @@ -239,43 +260,52 @@ - (void)setLineDasharray:(MGLStyleValue *> *)lineDasharray { - (void)setLineGapWidth:(MGLStyleValue *)lineGapWidth { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineGapWidth); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(lineGapWidth); self.rawLayer->setLineGapWidth(mbglValue); } - (MGLStyleValue *)lineGapWidth { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineGapWidth() ?: self.rawLayer->getDefaultLineGapWidth(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getLineGapWidth(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultLineGapWidth()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setLineOffset:(MGLStyleValue *)lineOffset { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOffset); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(lineOffset); self.rawLayer->setLineOffset(mbglValue); } - (MGLStyleValue *)lineOffset { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineOffset() ?: self.rawLayer->getDefaultLineOffset(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getLineOffset(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultLineOffset()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setLineOpacity:(MGLStyleValue *)lineOpacity { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(lineOpacity); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(lineOpacity); self.rawLayer->setLineOpacity(mbglValue); } - (MGLStyleValue *)lineOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineOpacity() ?: self.rawLayer->getDefaultLineOpacity(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getLineOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultLineOpacity()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } - (void)setLinePattern:(MGLStyleValue *)linePattern { @@ -288,7 +318,10 @@ - (void)setLinePattern:(MGLStyleValue *)linePattern { - (MGLStyleValue *)linePattern { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLinePattern() ?: self.rawLayer->getDefaultLinePattern(); + auto propertyValue = self.rawLayer->getLinePattern(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultLinePattern()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -302,7 +335,10 @@ - (void)setLineTranslate:(MGLStyleValue *)lineTranslate { - (MGLStyleValue *)lineTranslate { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineTranslate() ?: self.rawLayer->getDefaultLineTranslate(); + auto propertyValue = self.rawLayer->getLineTranslate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultLineTranslate()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -311,12 +347,16 @@ - (void)setLineTranslateAnchor:(MGLStyleValue *)lineTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(lineTranslateAnchor); self.rawLayer->setLineTranslateAnchor(mbglValue); + self.rawLayer->setLineTranslateAnchor(mbglValue); } - (MGLStyleValue *)lineTranslateAnchor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineTranslateAnchor() ?: self.rawLayer->getDefaultLineTranslateAnchor(); + auto propertyValue = self.rawLayer->getLineTranslateAnchor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultLineTranslateAnchor()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -330,9 +370,12 @@ - (void)setLineWidth:(MGLStyleValue *)lineWidth { - (MGLStyleValue *)lineWidth { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getLineWidth() ?: self.rawLayer->getDefaultLineWidth(); + auto propertyValue = self.rawLayer->getLineWidth(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultLineWidth()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } -@end +@end \ No newline at end of file diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index e61532773c3..ae92f54b0c4 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -92,7 +92,10 @@ - (void)setMaximumRasterBrightness:(MGLStyleValue *)maximumRasterBri - (MGLStyleValue *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterBrightnessMax() ?: self.rawLayer->getDefaultRasterBrightnessMax(); + auto propertyValue = self.rawLayer->getRasterBrightnessMax(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterBrightnessMax()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -111,7 +114,10 @@ - (void)setMinimumRasterBrightness:(MGLStyleValue *)minimumRasterBri - (MGLStyleValue *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterBrightnessMin() ?: self.rawLayer->getDefaultRasterBrightnessMin(); + auto propertyValue = self.rawLayer->getRasterBrightnessMin(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterBrightnessMin()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -130,7 +136,10 @@ - (void)setRasterContrast:(MGLStyleValue *)rasterContrast { - (MGLStyleValue *)rasterContrast { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterContrast() ?: self.rawLayer->getDefaultRasterContrast(); + auto propertyValue = self.rawLayer->getRasterContrast(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterContrast()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -144,7 +153,10 @@ - (void)setRasterFadeDuration:(MGLStyleValue *)rasterFadeDuration { - (MGLStyleValue *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterFadeDuration() ?: self.rawLayer->getDefaultRasterFadeDuration(); + auto propertyValue = self.rawLayer->getRasterFadeDuration(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterFadeDuration()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -158,7 +170,10 @@ - (void)setRasterHueRotation:(MGLStyleValue *)rasterHueRotation { - (MGLStyleValue *)rasterHueRotation { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterHueRotate() ?: self.rawLayer->getDefaultRasterHueRotate(); + auto propertyValue = self.rawLayer->getRasterHueRotate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterHueRotate()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -177,7 +192,10 @@ - (void)setRasterOpacity:(MGLStyleValue *)rasterOpacity { - (MGLStyleValue *)rasterOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterOpacity() ?: self.rawLayer->getDefaultRasterOpacity(); + auto propertyValue = self.rawLayer->getRasterOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterOpacity()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -191,9 +209,12 @@ - (void)setRasterSaturation:(MGLStyleValue *)rasterSaturation { - (MGLStyleValue *)rasterSaturation { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getRasterSaturation() ?: self.rawLayer->getDefaultRasterSaturation(); + auto propertyValue = self.rawLayer->getRasterSaturation(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultRasterSaturation()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } -@end +@end \ No newline at end of file diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index baeed3b8829..bee1416891c 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -14,7 +14,7 @@ #import "MGLStyleValue_Private.h" #import "MGL<%- camelize(type) %>StyleLayer.h" -#include _layer.hpp> +#include _layer.hpp> <% if (containsEnumerationProperties) { -%> namespace mbgl { @@ -166,24 +166,44 @@ namespace mbgl { - (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { MGLAssertStyleLayerIsValid(); +<% if (property["property-function"] == true) { -%> +<% if (property.type == "enum") { -%> + auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); +<% } else { -%> + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenPropertyValue(<%- objCName(property) %>); +<% } -%> +<% } else { -%> <% if (property.type == "enum") { -%> auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); - self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); - self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } -%> +<% } -%> + self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); } - (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); + auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>(); +<% if (property["property-function"] == true) { -%> + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>()); + } + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(propertyValue); +<% } else { -%> <% if (property.type == "enum") { -%> + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>()); + } return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>()); + } return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> +<% } -%> } <% if (property.original) { %> @@ -205,24 +225,45 @@ namespace mbgl { - (void)set<%- camelize(property.name) %>:(MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCName(property) %> { MGLAssertStyleLayerIsValid(); +<% if (property["property-function"] == true) { -%> +<% if (property.type == "enum") { -%> + auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(originalPropertyName(property)) %>>().toEnumPropertyValue(<%- objCName(property) %>); +<% } else { -%> + auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenPropertyValue(<%- objCName(property) %>); +<% } -%> +<% } else { -%> <% if (property.type == "enum") { -%> auto mbglValue = MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumPropertyValue(<%- objCName(property) %>); self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } else { -%> auto mbglValue = MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toPropertyValue(<%- objCName(property) %>); - self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); <% } -%> +<% } -%> + self.rawLayer->set<%- camelize(originalPropertyName(property)) %>(mbglValue); } - (MGLStyleValue<<%- propertyType(property, true) %>> *)<%- objCGetter(property) %> { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>() ?: self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>(); + auto propertyValue = self.rawLayer->get<%- camelize(originalPropertyName(property)) %>(); +<% if (property["property-function"] == true) { -%> + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>()); + } + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toDataDrivenStyleValue(propertyValue); +<% } else { -%> <% if (property.type == "enum") { -%> + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>()); + } return MGLStyleValueTransformer, NSValue *, mbgl::style::<%- mbglType(property) %>, MGL<%- camelize(property.name) %>>().toEnumStyleValue(propertyValue); <% } else { -%> + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(self.rawLayer->getDefault<%- camelize(originalPropertyName(property)) %>()); + } return MGLStyleValueTransformer<<%- valueTransformerArguments(property).join(', ') %>>().toStyleValue(propertyValue); <% } -%> +<% } -%> } <% if (property.original) { %> @@ -234,4 +275,4 @@ namespace mbgl { <% } -%> <% } -%> -@end +@end \ No newline at end of file diff --git a/platform/darwin/src/MGLStyleValue.h b/platform/darwin/src/MGLStyleValue.h index 315d48b7619..f51e884891a 100644 --- a/platform/darwin/src/MGLStyleValue.h +++ b/platform/darwin/src/MGLStyleValue.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN An `MGLStyleValue` object is a generic container for a style attribute value. The layout and paint attribute properties of `MGLStyleLayer` can be set to `MGLStyleValue` objects. - + The `MGLStyleValue` class itself represents a class cluster. Under the hood, a particular `MGLStyleValue` object may be either an `MGLStyleConstantValue` to represent a constant value or an `MGLStyleFunction` to represent a value @@ -41,6 +41,8 @@ MGL_EXPORT */ + (instancetype)valueWithRawValue:(T)rawValue; +#pragma mark Camera function values + /** Creates and returns an `MGLStyleFunction` object representing a linear zoom level function with any number of stops. @@ -50,6 +52,7 @@ MGL_EXPORT */ + (instancetype)valueWithStops:(NSDictionary *> *)stops; +// TODO: deprecate in favor of the same API but with "exponentialStops" /** Creates and returns an `MGLStyleFunction` object representing a zoom level function with an exponential base and any number of stops. @@ -60,6 +63,29 @@ MGL_EXPORT */ + (instancetype)valueWithBase:(CGFloat)base stops:(NSDictionary *> *)stops; +// TODO: API docs ++ (instancetype)valueWithIntervalStops:(NSDictionary *> *)intervalStops; + +#pragma mark Source function values + +// TODO: API docs ++ (instancetype)valueWithAttributeName:(NSString *)attributeName categoricalStops:(NSDictionary *> *)categoricalStops defaultValue:(MGLStyleValue * _Nullable)defaultValue; + +// TODO: API docs ++ (instancetype)valueWithAttributeName:(NSString *)attributeName exponentialStops:(NSDictionary *> *)exponentialStops; + +// TODO: API docs ++ (instancetype)valueWithAttributeName:(NSString *)attributeName base:(CGFloat)base exponentialStops:(NSDictionary *> *)exponentialStops; + +// TODO: API docs ++ (instancetype)valueWithAttributeName:(NSString *)attributeName intervalStops:(NSDictionary *> *)intervalStops; + +// TODO: API docs ++ (instancetype)valueWithAttributeName:(NSString *)attributeName; + +// TODO: API docs ++ (instancetype)valueWithAttributeName:(NSString *)attributeName compositeCategoricalStops:(NSDictionary *> *)categoricalStops; + @end /** @@ -178,4 +204,156 @@ MGL_EXPORT @end +/** + An `MGLStyleIntervalFunction` is a value function defining a style value that + changes as the zoom level changes over a discrete domain. The layout and paint + attribute properties of an `MGLStyleLayer` object can be set to + `MGLStyleIntervalFunction` objects. Use a zoom level function to create the + illusion of depth and control data density. + + The `MGLStyleIntervalFunction` class takes a generic parameter `T` that indicates the + Foundation class being wrapped by this class. + */ +@interface MGLStyleIntervalFunction : MGLStyleValue + +#pragma mark Creating a Style Interval Function + +// TODO: API docs ++ (instancetype)functionWithIntervalStops:(NSDictionary *> *)intervalStops; + +#pragma mark Initializing a Style Interval Function + +// TODO: API docs +- (instancetype)initWithIntervalStops:(NSDictionary *> *)intervalStops NS_DESIGNATED_INITIALIZER; + +#pragma mark Accessing the Parameters of a Style Interval Function + +// TODO: API docs +@property (nonatomic, copy) NSDictionary *> *stops; + +@end + +//todo: break MGLStyleSourceFunction into SourceCategorical, SourceExponential, SourceInterval, and SourceIdentity + +// TODO: API docs +@interface MGLStyleSourceCategoricalFunction : MGLStyleValue + +#pragma mark Creating a Style Source Categorical Function + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName categoricalStops:(NSDictionary *> *)categoricalStops defaultValue:(MGLStyleValue * _Nullable)defaultValue; + +#pragma mark Initializing a Style Source Categorical Function + +// TODO: API docs +- (instancetype)initWithAttributeName:(NSString *)attributeName categoricalStops:(NSDictionary *> *)categoricalStops defaultValue:(MGLStyleValue * _Nullable)defaultValue NS_DESIGNATED_INITIALIZER; + +#pragma mark Accessing the Parameters of a Style Source Categorical Function + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +// TODO: API docs +@property (nonatomic, copy) NSDictionary *> *stops; + +// TODO: API docs +@property (nonatomic, nullable) MGLStyleValue *defaultValue; + +@end + +// TODO: API docs +@interface MGLStyleSourceExponentialFunction : MGLStyleValue + +#pragma mark Creating a Style Source Exponential Function + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName exponentialStops:(NSDictionary *> *)exponentialStops; + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName base:(CGFloat)base exponentialStops:(NSDictionary *> *)exponentialStops; + +#pragma mark Initializing a Style Source Exponential Function + +// TODO: API docs +- (instancetype)initWithAttributeName:(NSString *)attributeName base:(CGFloat)base exponentialStops:(NSDictionary *> *)exponentialStops NS_DESIGNATED_INITIALIZER; + +#pragma mark Accessing the Parameters of a Style Source Exponential Function + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +// TODO: API docs +@property (nonatomic) CGFloat base; + +// TODO: API docs +@property (nonatomic, copy) NSDictionary *> *stops; + +@end + +// TODO: API docs +@interface MGLStyleSourceIntervalFunction : MGLStyleValue + +#pragma mark Creating a Style Source Interval Function + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName intervalStops:(NSDictionary *> *)intervalStops; + +#pragma mark Initializing a Style Source Interval Function + +// TODO: API docs +- (instancetype)initWithAttributeName:(NSString *)attributeName intervalStops:(NSDictionary *> *)intervalStops NS_DESIGNATED_INITIALIZER; + +#pragma mark Accessing the Parameters of a Style Source Interval Function + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +// TODO: API docs +@property (nonatomic, copy) NSDictionary *> *stops; + +@end + +// TODO: API docs +@interface MGLStyleSourceIdentityFunction : MGLStyleValue + +#pragma mark Creating a Style Source Identity Function + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName; + +#pragma mark Initializing a Style Source Identity Function + +// TODO: API docs +- (instancetype)initWithAttributeName:(NSString *)attributeName NS_DESIGNATED_INITIALIZER; + +#pragma mark Accessing the Parameters of a Style Source Identity Function + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +@end + +// TODO: API docs +@interface MGLStyleCompositeCategoricalFunction : MGLStyleValue + +#pragma mark Creating a Style Composite Categorical Function + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName compositeCategoricalStops:(NSDictionary *> *)categoricalStops; + +#pragma mark Initializing a Style Composite Categorical Function + +// TODO: API docs +- (instancetype)initWithAttributeName:(NSString *)attributeName compositeCategoricalStops:(NSDictionary *> *)categoricalStops NS_DESIGNATED_INITIALIZER; + +#pragma mark Accessing the Parameters of a Style Composite Categorical Function + +// TODO: API docs +@property (nonatomic, copy) NSString *attributeName; + +// TODO: API docs +@property (nonatomic, copy) NSDictionary *> *stops; + +@end + NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLStyleValue.mm b/platform/darwin/src/MGLStyleValue.mm index 6ced819cd16..73aee9729be 100644 --- a/platform/darwin/src/MGLStyleValue.mm +++ b/platform/darwin/src/MGLStyleValue.mm @@ -14,6 +14,34 @@ + (instancetype)valueWithStops:(NSDictionary *)stops { return [MGLStyleFunction functionWithStops:stops]; } ++ (instancetype)valueWithIntervalStops:(NSDictionary *)intervalStops { + return [MGLStyleIntervalFunction functionWithIntervalStops:intervalStops]; +} + ++ (instancetype)valueWithAttributeName:(NSString *)attributeName categoricalStops:(NSDictionary *)categoricalStops defaultValue:(id)defaultValue { + return [MGLStyleSourceCategoricalFunction functionWithAttributeName:attributeName categoricalStops:categoricalStops defaultValue:defaultValue]; +} + ++ (instancetype)valueWithAttributeName:(NSString *)attributeName exponentialStops:(NSDictionary *)exponentialStops { + return [MGLStyleSourceExponentialFunction functionWithAttributeName:attributeName exponentialStops:exponentialStops]; +} + ++ (instancetype)valueWithAttributeName:(NSString *)attributeName base:(CGFloat)base exponentialStops:(NSDictionary *)exponentialStops { + return [MGLStyleSourceExponentialFunction functionWithAttributeName:attributeName base:base exponentialStops:exponentialStops]; +} + ++ (instancetype)valueWithAttributeName:(NSString *)attributeName intervalStops:(NSDictionary *)intervalStops { + return [MGLStyleSourceIntervalFunction functionWithAttributeName:attributeName intervalStops:intervalStops]; +} + ++ (instancetype)valueWithAttributeName:(NSString *)attributeName { + return [MGLStyleSourceIdentityFunction functionWithAttributeName:attributeName]; +} + ++ (instancetype)valueWithAttributeName:(NSString *)attributeName compositeCategoricalStops:(NSDictionary *)categoricalStops { + return [MGLStyleCompositeCategoricalFunction functionWithAttributeName:attributeName compositeCategoricalStops:categoricalStops]; +} + @end @implementation MGLStyleConstantValue @@ -90,3 +118,240 @@ - (NSUInteger)hash { } @end + +@implementation MGLStyleIntervalFunction + ++ (instancetype)functionWithIntervalStops:(NSDictionary *)stops { + return [[self alloc] initWithIntervalStops:stops]; +} + +- (instancetype)init { + return [self initWithIntervalStops:@{}]; +} + +- (instancetype)initWithIntervalStops:(NSDictionary *)stops { + if (self == [super init]) { + _stops = stops; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, stops = %@>", NSStringFromClass([self class]), (void *)self, self.stops]; +} + +- (BOOL)isEqual:(MGLStyleIntervalFunction *)other { + return ([other isKindOfClass:[self class]] && [other.stops isEqualToDictionary:self.stops]); +} + +- (NSUInteger)hash { + return self.stops.hash; +} + +@end + +@implementation MGLStyleSourceCategoricalFunction + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName categoricalStops:(NSDictionary *)categoricalStops defaultValue:(id)defaultValue { + return [[self alloc] initWithAttributeName:attributeName categoricalStops:categoricalStops defaultValue:defaultValue]; +} + +- (instancetype)init { + return [self initWithAttributeName:@"" categoricalStops:@{} defaultValue:nil]; +} + +- (instancetype)initWithAttributeName:(NSString *)attributeName categoricalStops:(NSDictionary *)categoricalStops defaultValue:(id)defaultValue { + if (self == [super init]) { + _attributeName = attributeName; + _stops = categoricalStops; + _defaultValue = defaultValue; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, attributeName = %@, \ + categoricalStops = %@ \ + defaultValue = %@>", + NSStringFromClass([self class]), + (void *)self, + self.attributeName, + self.stops, + self.defaultValue]; +} + +- (BOOL)isEqual:(MGLStyleSourceCategoricalFunction *)other { + return ([other isKindOfClass:[self class]] && + [other.attributeName isEqual:self.attributeName] && + [other.stops isEqualToDictionary:self.stops] && + [other.defaultValue isEqual:self.defaultValue]); +} + +- (NSUInteger)hash { + return self.attributeName.hash + self.stops.hash + self.defaultValue.hash; +} + +@end + +@implementation MGLStyleSourceExponentialFunction + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName exponentialStops:(NSDictionary *)exponentialStops { + return [[self alloc] initWithAttributeName:attributeName base:1.0 exponentialStops:exponentialStops]; +} + +// TODO: API docs ++ (instancetype)functionWithAttributeName:(NSString *)attributeName base:(CGFloat)base exponentialStops:(NSDictionary *)exponentialStops { + return [[self alloc] initWithAttributeName:attributeName base:base exponentialStops:exponentialStops]; +} + +- (instancetype)init { + return [self initWithAttributeName:@"" base:0 exponentialStops:@{}]; +} + +- (instancetype)initWithAttributeName:(NSString *)attributeName base:(CGFloat)base exponentialStops:(NSDictionary *)exponentialStops { + if (self == [super init]) { + _attributeName = attributeName; + _base = base; + _stops = exponentialStops; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, attributeName = %@, \ + stops = %@ \ + base = %f>", + NSStringFromClass([self class]), + (void *)self, + self.attributeName, + self.stops, + self.base]; +} + +- (BOOL)isEqual:(MGLStyleSourceExponentialFunction *)other { + return ([other isKindOfClass:[self class]] && + [other.attributeName isEqual:self.attributeName] && + [other.stops isEqualToDictionary:self.stops] && + other.base == self.base); +} + +- (NSUInteger)hash { + return self.attributeName.hash + self.stops.hash + self.base; +} + +@end + +@implementation MGLStyleSourceIntervalFunction + ++ (instancetype)functionWithAttributeName:(NSString *)attributeName intervalStops:(NSDictionary *)intervalStops { + return [[self alloc] initWithAttributeName:attributeName intervalStops:intervalStops]; +} + +- (instancetype)init { + return [self initWithAttributeName:@"" intervalStops:@{}]; +} + +- (instancetype)initWithAttributeName:(NSString *)attributeName intervalStops:(NSDictionary *)intervalStops { + if (self == [super init]) { + _attributeName = attributeName; + _stops = intervalStops; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, attributeName = %@, \ + stops = %@>", + NSStringFromClass([self class]), + (void *)self, + self.attributeName, + self.stops]; +} + +- (BOOL)isEqual:(MGLStyleSourceExponentialFunction *)other { + return ([other isKindOfClass:[self class]] && + [other.attributeName isEqual:self.attributeName] && + [other.stops isEqualToDictionary:self.stops]); +} + +- (NSUInteger)hash { + return self.attributeName.hash + self.stops.hash; +} + +@end + +@implementation MGLStyleSourceIdentityFunction + ++ (instancetype)functionWithAttributeName:(NSString *)attributeName { + return [[self alloc] initWithAttributeName:attributeName]; +} + +- (instancetype)init { + return [self initWithAttributeName:@""]; +} + +- (instancetype)initWithAttributeName:(NSString *)attributeName { + if (self == [super init]) { + _attributeName = attributeName; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, attributeName = %@>", + NSStringFromClass([self class]), + (void *)self, + self.attributeName]; +} + +- (BOOL)isEqual:(MGLStyleSourceExponentialFunction *)other { + return ([other isKindOfClass:[self class]] && + [other.attributeName isEqual:self.attributeName]); +} + +- (NSUInteger)hash { + return self.attributeName.hash; +} + +@end + +@implementation MGLStyleCompositeCategoricalFunction + ++ (instancetype)functionWithAttributeName:(NSString *)attributeName compositeCategoricalStops:(NSDictionary *)categoricalStops { + return [[self alloc] initWithAttributeName:attributeName compositeCategoricalStops:categoricalStops]; +} + +- (instancetype)init { + return [self initWithAttributeName:@"" compositeCategoricalStops:@{}]; +} + +- (instancetype)initWithAttributeName:(NSString *)attributeName compositeCategoricalStops:(NSDictionary *)categoricalStops { + if (self == [super init]) { + _attributeName = attributeName; + _stops = categoricalStops; + } + return self; +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, attributeName = %@, \ + stops = %@>", + NSStringFromClass([self class]), + (void *)self, + self.attributeName, + self.stops]; +} + +- (BOOL)isEqual:(MGLStyleSourceExponentialFunction *)other { + return ([other isKindOfClass:[self class]] && + [other.attributeName isEqual:self.attributeName] && + [other.stops isEqualToDictionary:self.stops]); +} + +- (NSUInteger)hash { + return self.attributeName.hash + self.stops.hash; +} + +@end diff --git a/platform/darwin/src/MGLStyleValue_Private.h b/platform/darwin/src/MGLStyleValue_Private.h index 492ce20f1a9..1da96c297fe 100644 --- a/platform/darwin/src/MGLStyleValue_Private.h +++ b/platform/darwin/src/MGLStyleValue_Private.h @@ -4,65 +4,211 @@ #import "NSValue+MGLStyleAttributeAdditions.h" #import "MGLTypes.h" -#import "MGLLineStyleLayer.h" + #import +#include + #if TARGET_OS_IPHONE #import "UIColor+MGLAdditions.h" #else #import "NSColor+MGLAdditions.h" #endif -#include - template class MGLStyleValueTransformer { public: - + + // Convert an mbgl property value into an mgl style value MGLStyleValue *toStyleValue(const mbgl::style::PropertyValue &mbglValue) { - if (mbglValue.isConstant()) { - return toStyleConstantValue(mbglValue.asConstant()); - } else if (mbglValue.isFunction()) { - return toStyleFunction(mbglValue.asFunction()); - } else { - return nil; - } + PropertyValueEvaluator evaluator; + return mbglValue.evaluate(evaluator); + } + + // Convert an mbgl data driven property value into an mgl style value + MGLStyleValue *toDataDrivenStyleValue(const mbgl::style::DataDrivenPropertyValue &mbglValue) { + PropertyValueEvaluator evaluator; + return mbglValue.evaluate(evaluator); } + // Convert an mbgl property value containing an enum into an mgl style value template ::value>::type, typename MGLEnum = ObjCEnum, class = typename std::enable_if::value>::type> MGLStyleValue *toEnumStyleValue(const mbgl::style::PropertyValue &mbglValue) { - if (mbglValue.isConstant()) { - return toEnumStyleConstantValue<>(mbglValue.asConstant()); - } else if (mbglValue.isFunction()) { - const auto &mbglStops = mbglValue.asFunction().getStops(); - NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()]; - for (const auto &mbglStop : mbglStops) { - stops[@(mbglStop.first)] = toEnumStyleConstantValue<>(mbglStop.second); - } - return [MGLStyleFunction functionWithBase:mbglValue.asFunction().getBase() stops:stops]; + EnumPropertyValueEvaluator evaluator; + return mbglValue.evaluate(evaluator); + } + + // Convert an mgl style value into a mgl property value + mbgl::style::PropertyValue toPropertyValue(MGLStyleValue *value) { + if ([value isKindOfClass:[MGLStyleConstantValue class]]) { + MBGLType mbglValue; + id mglValue = [(MGLStyleConstantValue *)value rawValue]; + getMBGLValue(mglValue, mbglValue); + return mbglValue; + } else if (value) { + [NSException raise:@"MGLAbstractClassException" format: + @"The style value %@ cannot be applied to the style. " + @"Make sure the style value was created as a member of a concrete subclass of MGLStyleValue.", + NSStringFromClass([value class])]; + return {}; } else { - return nil; + return {}; } } - mbgl::style::PropertyValue toPropertyValue(MGLStyleValue *value) { + // Convert an mgl style value into a mgl data driven property value + mbgl::style::DataDrivenPropertyValue toDataDrivenPropertyValue(MGLStyleValue *value) { if ([value isKindOfClass:[MGLStyleConstantValue class]]) { MBGLType mbglValue; - getMBGLValue([(MGLStyleConstantValue *)value rawValue], mbglValue); + id mglValue = [(MGLStyleConstantValue *)value rawValue]; + getMBGLValue(mglValue, mbglValue); return mbglValue; } else if ([value isKindOfClass:[MGLStyleFunction class]]) { MGLStyleFunction *function = (MGLStyleFunction *)value; - __block std::vector> mbglStops; + + __block std::map stops = {}; [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); auto mbglStopValue = toPropertyValue(stopValue); NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); - mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant()); + stops[zoomKey.floatValue] = mbglStopValue.asConstant(); }]; - return mbgl::style::Function({{mbglStops}}, function.base); + + // Camera function with Exponential stops + mbgl::style::ExponentialStops exponentialStops = {stops, (float)function.base}; + mbgl::style::CameraFunction cameraFunction = {exponentialStops}; + + return cameraFunction; + } else if ([value isKindOfClass:[MGLStyleIntervalFunction class]]) { + MGLStyleIntervalFunction *function = (MGLStyleIntervalFunction *)value; + + __block std::map stops = {}; + [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { + NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); + auto mbglStopValue = toPropertyValue(stopValue); + NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); + stops[zoomKey.floatValue] = mbglStopValue.asConstant(); + }]; + + // Camera function with Interval stops + mbgl::style::IntervalStops intervalStops = {stops}; + mbgl::style::CameraFunction cameraFunction = {intervalStops}; + + return cameraFunction; + } else if ([value isKindOfClass:[MGLStyleSourceCategoricalFunction class]]) { + MGLStyleSourceCategoricalFunction *function = (MGLStyleSourceCategoricalFunction *)value; + + __block std::map stops = {}; + + [function.stops enumerateKeysAndObjectsUsingBlock:^(id categoryKey, MGLStyleValue *stopValue, BOOL *stop) { + NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); + auto mbglStopValue = toPropertyValue(stopValue); + NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); + + if ([categoryKey isKindOfClass:[NSString class]]) { + const std::string& convertedValueKey = [((NSString *)categoryKey) UTF8String]; + stops[mbgl::style::CategoricalValue(convertedValueKey)] = mbglStopValue.asConstant(); + } else if ([categoryKey isKindOfClass:[NSNumber class]]) { + NSNumber *key = (NSNumber *)categoryKey; + if ((strcmp([key objCType], @encode(char)) == 0) || + (strcmp([key objCType], @encode(BOOL)) == 0)) { + stops[mbgl::style::CategoricalValue((bool)[key boolValue])] = mbglStopValue.asConstant(); + } else if (strcmp([key objCType], @encode(double)) == 0 || + strcmp([key objCType], @encode(float)) == 0) { + NSCAssert(mbglStopValue.isConstant(), @"Categorical stop keys must be strings, booleans, or integers"); + } else if ([key compare:@(0)] == NSOrderedDescending || + [key compare:@(0)] == NSOrderedSame || + [key compare:@(0)] == NSOrderedAscending) { + stops[mbgl::style::CategoricalValue((int64_t)[key integerValue])] = mbglStopValue.asConstant(); + } + } + }]; + mbgl::style::CategoricalStops categoricalStops = {stops}; + if (function.defaultValue) { + NSCAssert([function.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant"); + MBGLType mbglValue; + id mglValue = [(MGLStyleConstantValue *)function.defaultValue rawValue]; + getMBGLValue(mglValue, mbglValue); + categoricalStops.defaultValue = mbglValue; + } + mbgl::style::SourceFunction sourceFunction = {function.attributeName.UTF8String, categoricalStops}; + return sourceFunction; + } else if ([value isKindOfClass:[MGLStyleSourceExponentialFunction class]]) { + MGLStyleSourceExponentialFunction *function = (MGLStyleSourceExponentialFunction *)value; + __block std::map stops = {}; + [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { + NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); + auto mbglStopValue = toPropertyValue(stopValue); + NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); + stops[zoomKey.floatValue] = mbglStopValue.asConstant(); + }]; + mbgl::style::ExponentialStops exponentialStops = {stops, (float)function.base}; + mbgl::style::SourceFunction sourceFunction = {function.attributeName.UTF8String, exponentialStops}; + return sourceFunction; + } else if ([value isKindOfClass:[MGLStyleSourceIntervalFunction class]]) { + MGLStyleSourceIntervalFunction *function = (MGLStyleSourceIntervalFunction *)value; + __block std::map stops = {}; + [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { + NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); + auto mbglStopValue = toPropertyValue(stopValue); + NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); + stops[zoomKey.floatValue] = mbglStopValue.asConstant(); + }]; + mbgl::style::IntervalStops intervalStops = {stops}; + mbgl::style::SourceFunction sourceFunction = {function.attributeName.UTF8String, intervalStops}; + return sourceFunction; + } else if ([value isKindOfClass:[MGLStyleSourceIdentityFunction class]]) { + MGLStyleSourceIdentityFunction *function = (MGLStyleSourceIdentityFunction *)value; + mbgl::style::IdentityStops identityStops; + mbgl::style::SourceFunction sourceFunction = {function.attributeName.UTF8String, identityStops}; + return sourceFunction; + } else if ([value isKindOfClass:[MGLStyleCompositeCategoricalFunction class]]) { + MGLStyleCompositeCategoricalFunction *function = (MGLStyleCompositeCategoricalFunction *)value; + __block std::map> compositeStops = {}; + [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { + NSCAssert([stopValue isKindOfClass:[MGLStyleSourceCategoricalFunction class]], @"Stops should be MGLStyleSourceCategoricalFunction"); + + MGLStyleSourceCategoricalFunction *innerFunction = (MGLStyleSourceCategoricalFunction *)stopValue; + __block std::map stops = {}; + + [innerFunction.stops enumerateKeysAndObjectsUsingBlock:^(id categoryKey, MGLStyleValue *innerStopValue, BOOL *innerStop) { + NSCAssert([innerStopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); + auto mbglStopValue = toPropertyValue(innerStopValue); + NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); + + if ([categoryKey isKindOfClass:[NSString class]]) { + const std::string& convertedValueKey = [((NSString *)categoryKey) UTF8String]; + stops[mbgl::style::CategoricalValue(convertedValueKey)] = mbglStopValue.asConstant(); + } else if ([categoryKey isKindOfClass:[NSNumber class]]) { + NSNumber *key = (NSNumber *)categoryKey; + if ((strcmp([key objCType], @encode(char)) == 0) || + (strcmp([key objCType], @encode(BOOL)) == 0)) { + stops[mbgl::style::CategoricalValue((bool)[key boolValue])] = mbglStopValue.asConstant(); + } else if (strcmp([key objCType], @encode(double)) == 0 || + strcmp([key objCType], @encode(float)) == 0) { + NSCAssert(mbglStopValue.isConstant(), @"Categorical stop keys must be strings, booleans, or integers"); + } else if ([key compare:@(0)] == NSOrderedDescending || + [key compare:@(0)] == NSOrderedSame || + [key compare:@(0)] == NSOrderedAscending) { + stops[mbgl::style::CategoricalValue((int64_t)[key integerValue])] = mbglStopValue.asConstant(); + } + } + }]; + mbgl::style::CategoricalStops categoricalStops = {stops}; + if (innerFunction.defaultValue) { + NSCAssert([innerFunction.defaultValue isKindOfClass:[MGLStyleConstantValue class]], @"Default value must be constant"); + MBGLType mbglValue; + id mglValue = [(MGLStyleConstantValue *)innerFunction.defaultValue rawValue]; + getMBGLValue(mglValue, mbglValue); + categoricalStops.defaultValue = mbglValue; + } + compositeStops[zoomKey.floatValue] = categoricalStops; + }]; + mbgl::style::CompositeFunction compositeFunction = {function.attributeName.UTF8String, compositeStops}; + return compositeFunction; } else if (value) { [NSException raise:@"MGLAbstractClassException" format: @"The style value %@ cannot be applied to the style. " @@ -74,6 +220,7 @@ class MGLStyleValueTransformer { } } + // Convert an mgl style value containing an enum into a mgl property value containing an enum template ::value>::type, typename MGLEnum = ObjCEnum, @@ -83,16 +230,6 @@ class MGLStyleValueTransformer { MBGLEnum mbglValue; getMBGLValue([(MGLStyleConstantValue *)value rawValue], mbglValue); return mbglValue; - } else if ([value isKindOfClass:[MGLStyleFunction class]]) { - MGLStyleFunction *function = (MGLStyleFunction *)value; - __block std::vector> mbglStops; - [function.stops enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull zoomKey, MGLStyleValue * _Nonnull stopValue, BOOL * _Nonnull stop) { - NSCAssert([stopValue isKindOfClass:[MGLStyleValue class]], @"Stops should be MGLStyleValues"); - auto mbglStopValue = toEnumPropertyValue(stopValue); - NSCAssert(mbglStopValue.isConstant(), @"Stops must be constant"); - mbglStops.emplace_back(zoomKey.floatValue, mbglStopValue.asConstant()); - }]; - return mbgl::style::Function({{mbglStops}}, function.base); } else if (value) { [NSException raise:@"MGLAbstractClassException" format: @"The style value %@ cannot be applied to the style. " @@ -104,77 +241,19 @@ class MGLStyleValueTransformer { } } -private: - - MGLStyleConstantValue *toStyleConstantValue(const MBGLType mbglValue) { - auto rawValue = toMGLRawStyleValue(mbglValue); - return [MGLStyleConstantValue valueWithRawValue:rawValue]; - } - - MGLStyleFunction *toStyleFunction(const mbgl::style::Function &mbglFunction) { - const auto &mbglStops = mbglFunction.getStops(); - NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()]; - for (const auto &mbglStop : mbglStops) { - auto rawValue = toMGLRawStyleValue(mbglStop.second); - stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue]; - } - return [MGLStyleFunction functionWithBase:mbglFunction.getBase() stops:stops]; - } - - template ::value>::type, - typename MGLEnum = ObjCEnum, - class = typename std::enable_if::value>::type> - MGLStyleConstantValue *toEnumStyleConstantValue(const MBGLEnum mbglValue) { - auto str = mbgl::Enum::toString(mbglValue); - MGLEnum mglType = *mbgl::Enum::toEnum(str); - return [MGLStyleConstantValue valueWithRawValue:[NSValue value:&mglType withObjCType:@encode(MGLEnum)]]; - } - - NSNumber *toMGLRawStyleValue(const bool mbglStopValue) { - return @(mbglStopValue); - } - - NSNumber *toMGLRawStyleValue(const float mbglStopValue) { - return @(mbglStopValue); - } - - NSString *toMGLRawStyleValue(const std::string &mbglStopValue) { - return @(mbglStopValue.c_str()); - } - - // Offsets - NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { - return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; - } - - // Padding - NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { - return [NSValue mgl_valueWithPaddingArray:mbglStopValue]; - } - - MGLColor *toMGLRawStyleValue(const mbgl::Color mbglStopValue) { - return [MGLColor mgl_colorWithColor:mbglStopValue]; - } - - ObjCType toMGLRawStyleValue(const std::vector &mbglStopValue) { - NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()]; - for (const auto &mbglElement: mbglStopValue) { - [array addObject:toMGLRawStyleValue(mbglElement)]; - } - return array; - } - -private: +private: // Private utilities for converting from mgl to mbgl values + // Bool void getMBGLValue(NSNumber *rawValue, bool &mbglValue) { mbglValue = !!rawValue.boolValue; } - + + // Float void getMBGLValue(NSNumber *rawValue, float &mbglValue) { mbglValue = rawValue.floatValue; } - + + // String void getMBGLValue(NSString *rawValue, std::string &mbglValue) { mbglValue = rawValue.UTF8String; } @@ -188,11 +267,13 @@ class MGLStyleValueTransformer { void getMBGLValue(NSValue *rawValue, std::array &mbglValue) { mbglValue = rawValue.mgl_paddingArrayValue; } - + + // Color void getMBGLValue(MGLColor *rawValue, mbgl::Color &mbglValue) { mbglValue = rawValue.mgl_color; } - + + // Array void getMBGLValue(ObjCType rawValue, std::vector &mbglValue) { mbglValue.reserve(rawValue.count); for (id obj in rawValue) { @@ -213,4 +294,178 @@ class MGLStyleValueTransformer { auto str = mbgl::Enum::toString(mglEnum); mbglValue = *mbgl::Enum::toEnum(str); } + +private: // Private utilities for converting from mbgl to mgl values + + // Bool + static NSNumber *toMGLRawStyleValue(const bool mbglStopValue) { + return @(mbglStopValue); + } + + // Float + static NSNumber *toMGLRawStyleValue(const float mbglStopValue) { + return @(mbglStopValue); + } + + // Integer + static NSNumber *toMGLRawStyleValue(const int64_t mbglStopValue) { + return @(mbglStopValue); + } + + // String + static NSString *toMGLRawStyleValue(const std::string &mbglStopValue) { + return @(mbglStopValue.c_str()); + } + + // Offsets + static NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { + return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; + } + + // Padding + static NSValue *toMGLRawStyleValue(const std::array &mbglStopValue) { + return [NSValue mgl_valueWithPaddingArray:mbglStopValue]; + } + + // Color + static MGLColor *toMGLRawStyleValue(const mbgl::Color mbglStopValue) { + return [MGLColor mgl_colorWithColor:mbglStopValue]; + } + + // Array + static ObjCType toMGLRawStyleValue(const std::vector &mbglStopValue) { + NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()]; + for (const auto &mbglElement: mbglStopValue) { + [array addObject:toMGLRawStyleValue(mbglElement)]; + } + return array; + } + + // Enumerations + template + static NSValue *toMGLRawStyleValue(const MBGLEnum &value) { + auto str = mbgl::Enum::toString(value); + MGLEnum mglType = *mbgl::Enum::toEnum(str); + return [NSValue value:&mglType withObjCType:@encode(MGLEnum)]; + } + + // Converts mbgl stops to an equivilant NSDictionary for mgl + static NSMutableDictionary *toConvertedStops(const std::map &mbglStops) { + NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.size()]; + for (const auto &mbglStop : mbglStops) { + auto rawValue = toMGLRawStyleValue(mbglStop.second); + stops[@(mbglStop.first)] = [MGLStyleValue valueWithRawValue:rawValue]; + } + return stops; + } + + // Converts mbgl interval stop categorical values to an equivilant object for mgl + class CategoricalValueVisitor { + public: + id operator()(const bool value) { + return toMGLRawStyleValue(value); + } + + id operator()(const int64_t value) { + return toMGLRawStyleValue(value); + } + + id operator()(const std::string value) { + return toMGLRawStyleValue(value); + } + }; + + // Converts a source function and all possible mbgl source function stops into an equivilant mgl style value + class SourceFunctionStopsVisitor { + public: + id operator()(const mbgl::style::ExponentialStops &mbglStops) { + return [MGLStyleSourceExponentialFunction functionWithAttributeName:@(mbglFunction.property.c_str()) + base:mbglStops.base + exponentialStops:toConvertedStops(mbglStops.stops)]; + } + + id operator()(const mbgl::style::IntervalStops &mbglStops) { + return [MGLStyleSourceIntervalFunction functionWithAttributeName:@(mbglFunction.property.c_str()) + intervalStops:toConvertedStops(mbglStops.stops)]; + } + + id operator()(const mbgl::style::CategoricalStops &mbglStops) { + NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:mbglStops.stops.size()]; + for (const auto &mbglStop : mbglStops.stops) { + auto categoricalValue = mbglStop.first; + auto rawValue = toMGLRawStyleValue(mbglStop.second); + CategoricalValueVisitor categoricalValueVisitor; + id stopKey = apply_visitor(categoricalValueVisitor, categoricalValue); + stops[stopKey] = [MGLStyleValue valueWithRawValue:rawValue]; + } + MGLStyleValue *defaultValue = [MGLStyleValue valueWithRawValue:toMGLRawStyleValue(mbglStops.defaultValue)]; + return [MGLStyleSourceCategoricalFunction functionWithAttributeName:@(mbglFunction.property.c_str()) categoricalStops:stops defaultValue:defaultValue]; + } + + id operator()(const mbgl::style::IdentityStops &mbglStops) { + return [MGLStyleSourceIdentityFunction functionWithAttributeName:@(mbglFunction.property.c_str())]; + } + + const mbgl::style::SourceFunction &mbglFunction; + }; + + // Converts all possible mbgl camera function stops into an equivilant mgl style value + class CameraFunctionStopsVisitor { + public: + id operator()(const mbgl::style::ExponentialStops &mbglStops) { + return [MGLStyleFunction functionWithBase:mbglStops.base stops:toConvertedStops(mbglStops.stops)]; + } + + id operator()(const mbgl::style::IntervalStops &mbglStops) { + return [MGLStyleIntervalFunction functionWithIntervalStops:toConvertedStops(mbglStops.stops)]; + } + }; + + // Converts all types of mbgl property values containing enumerations into an equivilant mgl style value + template + class EnumPropertyValueEvaluator { + public: + id operator()(const mbgl::style::Undefined) const { + return nil; + } + + id operator()(const MBGLEnum &value) const { + auto str = mbgl::Enum::toString(value); + MGLEnum mglType = *mbgl::Enum::toEnum(str); + return [MGLStyleConstantValue valueWithRawValue:[NSValue value:&mglType withObjCType:@encode(MGLEnum)]]; + } + + id operator()(const mbgl::style::CameraFunction &mbglValue) const { + CameraFunctionStopsVisitor visitor; + return apply_visitor(visitor, mbglValue.stops); + } + }; + + // Converts all types of mbgl property values that don't contain enumerations into an equivilant mgl style value + class PropertyValueEvaluator { + public: + id operator()(const mbgl::style::Undefined) const { + return nil; + } + + id operator()(const MBGLType &value) const { + auto rawValue = toMGLRawStyleValue(value); + return [MGLStyleConstantValue valueWithRawValue:rawValue]; + } + + id operator()(const mbgl::style::CameraFunction &mbglValue) const { + CameraFunctionStopsVisitor visitor; + return apply_visitor(visitor, mbglValue.stops); + } + + id operator()(const mbgl::style::SourceFunction &mbglValue) const { + SourceFunctionStopsVisitor visitor { mbglValue }; + return apply_visitor(visitor, mbglValue.stops); + } + + // TODO: Implement me + id operator()(const mbgl::style::CompositeFunction &mbglValue) const { + return nil; + } + }; }; diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index 31c584b4732..a3476b9a69f 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -188,7 +188,10 @@ - (void)setIconAllowsOverlap:(MGLStyleValue *)iconAllowsOverlap { - (MGLStyleValue *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconAllowOverlap() ?: self.rawLayer->getDefaultIconAllowOverlap(); + auto propertyValue = self.rawLayer->getIconAllowOverlap(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconAllowOverlap()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -211,7 +214,10 @@ - (void)setIconIgnoresPlacement:(MGLStyleValue *)iconIgnoresPlacemen - (MGLStyleValue *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconIgnorePlacement() ?: self.rawLayer->getDefaultIconIgnorePlacement(); + auto propertyValue = self.rawLayer->getIconIgnorePlacement(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconIgnorePlacement()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -234,7 +240,10 @@ - (void)setIconImageName:(MGLStyleValue *)iconImageName { - (MGLStyleValue *)iconImageName { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconImage() ?: self.rawLayer->getDefaultIconImage(); + auto propertyValue = self.rawLayer->getIconImage(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconImage()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -250,15 +259,18 @@ - (void)setIconImage:(MGLStyleValue *)iconImage { - (void)setIconOffset:(MGLStyleValue *)iconOffset { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer, NSValue *>().toPropertyValue(iconOffset); + auto mbglValue = MGLStyleValueTransformer, NSValue *>().toDataDrivenPropertyValue(iconOffset); self.rawLayer->setIconOffset(mbglValue); } - (MGLStyleValue *)iconOffset { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconOffset() ?: self.rawLayer->getDefaultIconOffset(); - return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getIconOffset(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toDataDrivenStyleValue(self.rawLayer->getDefaultIconOffset()); + } + return MGLStyleValueTransformer, NSValue *>().toDataDrivenStyleValue(propertyValue); } - (void)setIconOptional:(MGLStyleValue *)iconOptional { @@ -271,7 +283,10 @@ - (void)setIconOptional:(MGLStyleValue *)iconOptional { - (MGLStyleValue *)isIconOptional { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconOptional() ?: self.rawLayer->getDefaultIconOptional(); + auto propertyValue = self.rawLayer->getIconOptional(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconOptional()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -285,22 +300,28 @@ - (void)setIconPadding:(MGLStyleValue *)iconPadding { - (MGLStyleValue *)iconPadding { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconPadding() ?: self.rawLayer->getDefaultIconPadding(); + auto propertyValue = self.rawLayer->getIconPadding(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconPadding()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } - (void)setIconRotation:(MGLStyleValue *)iconRotation { MGLAssertStyleLayerIsValid(); - auto mbglValue = MGLStyleValueTransformer().toPropertyValue(iconRotation); + auto mbglValue = MGLStyleValueTransformer().toDataDrivenPropertyValue(iconRotation); self.rawLayer->setIconRotate(mbglValue); } - (MGLStyleValue *)iconRotation { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconRotate() ?: self.rawLayer->getDefaultIconRotate(); - return MGLStyleValueTransformer().toStyleValue(propertyValue); + auto propertyValue = self.rawLayer->getIconRotate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toDataDrivenStyleValue(self.rawLayer->getDefaultIconRotate()); + } + return MGLStyleValueTransformer().toDataDrivenStyleValue(propertyValue); } @@ -322,7 +343,10 @@ - (void)setIconRotationAlignment:(MGLStyleValue *)iconRotationAlignme - (MGLStyleValue *)iconRotationAlignment { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconRotationAlignment() ?: self.rawLayer->getDefaultIconRotationAlignment(); + auto propertyValue = self.rawLayer->getIconRotationAlignment(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultIconRotationAlignment()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -336,7 +360,10 @@ - (void)setIconScale:(MGLStyleValue *)iconScale { - (MGLStyleValue *)iconScale { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconSize() ?: self.rawLayer->getDefaultIconSize(); + auto propertyValue = self.rawLayer->getIconSize(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconSize()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -359,7 +386,10 @@ - (void)setIconTextFit:(MGLStyleValue *)iconTextFit { - (MGLStyleValue *)iconTextFit { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconTextFit() ?: self.rawLayer->getDefaultIconTextFit(); + auto propertyValue = self.rawLayer->getIconTextFit(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultIconTextFit()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -373,7 +403,10 @@ - (void)setIconTextFitPadding:(MGLStyleValue *)iconTextFitPadding { - (MGLStyleValue *)iconTextFitPadding { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconTextFitPadding() ?: self.rawLayer->getDefaultIconTextFitPadding(); + auto propertyValue = self.rawLayer->getIconTextFitPadding(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultIconTextFitPadding()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -387,7 +420,10 @@ - (void)setKeepsIconUpright:(MGLStyleValue *)keepsIconUpright { - (MGLStyleValue *)keepsIconUpright { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconKeepUpright() ?: self.rawLayer->getDefaultIconKeepUpright(); + auto propertyValue = self.rawLayer->getIconKeepUpright(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconKeepUpright()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -410,7 +446,10 @@ - (void)setKeepsTextUpright:(MGLStyleValue *)keepsTextUpright { - (MGLStyleValue *)keepsTextUpright { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextKeepUpright() ?: self.rawLayer->getDefaultTextKeepUpright(); + auto propertyValue = self.rawLayer->getTextKeepUpright(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextKeepUpright()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -433,7 +472,10 @@ - (void)setMaximumTextAngle:(MGLStyleValue *)maximumTextAngle { - (MGLStyleValue *)maximumTextAngle { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextMaxAngle() ?: self.rawLayer->getDefaultTextMaxAngle(); + auto propertyValue = self.rawLayer->getTextMaxAngle(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextMaxAngle()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -456,7 +498,10 @@ - (void)setMaximumTextWidth:(MGLStyleValue *)maximumTextWidth { - (MGLStyleValue *)maximumTextWidth { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextMaxWidth() ?: self.rawLayer->getDefaultTextMaxWidth(); + auto propertyValue = self.rawLayer->getTextMaxWidth(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextMaxWidth()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -479,7 +524,10 @@ - (void)setSymbolAvoidsEdges:(MGLStyleValue *)symbolAvoidsEdges { - (MGLStyleValue *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getSymbolAvoidEdges() ?: self.rawLayer->getDefaultSymbolAvoidEdges(); + auto propertyValue = self.rawLayer->getSymbolAvoidEdges(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultSymbolAvoidEdges()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -502,7 +550,10 @@ - (void)setSymbolPlacement:(MGLStyleValue *)symbolPlacement { - (MGLStyleValue *)symbolPlacement { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getSymbolPlacement() ?: self.rawLayer->getDefaultSymbolPlacement(); + auto propertyValue = self.rawLayer->getSymbolPlacement(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultSymbolPlacement()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -516,7 +567,10 @@ - (void)setSymbolSpacing:(MGLStyleValue *)symbolSpacing { - (MGLStyleValue *)symbolSpacing { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getSymbolSpacing() ?: self.rawLayer->getDefaultSymbolSpacing(); + auto propertyValue = self.rawLayer->getSymbolSpacing(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultSymbolSpacing()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -530,7 +584,10 @@ - (void)setTextAllowsOverlap:(MGLStyleValue *)textAllowsOverlap { - (MGLStyleValue *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextAllowOverlap() ?: self.rawLayer->getDefaultTextAllowOverlap(); + auto propertyValue = self.rawLayer->getTextAllowOverlap(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextAllowOverlap()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -553,7 +610,10 @@ - (void)setTextAnchor:(MGLStyleValue *)textAnchor { - (MGLStyleValue *)textAnchor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextAnchor() ?: self.rawLayer->getDefaultTextAnchor(); + auto propertyValue = self.rawLayer->getTextAnchor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultTextAnchor()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -567,7 +627,10 @@ - (void)setTextField:(MGLStyleValue *)textField { - (MGLStyleValue *)textField { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextField() ?: self.rawLayer->getDefaultTextField(); + auto propertyValue = self.rawLayer->getTextField(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextField()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -581,7 +644,10 @@ - (void)setTextFont:(MGLStyleValue *> *)textFont { - (MGLStyleValue *> *)textFont { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextFont() ?: self.rawLayer->getDefaultTextFont(); + auto propertyValue = self.rawLayer->getTextFont(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(self.rawLayer->getDefaultTextFont()); + } return MGLStyleValueTransformer, NSArray *, std::string>().toStyleValue(propertyValue); } @@ -595,7 +661,10 @@ - (void)setTextIgnoresPlacement:(MGLStyleValue *)textIgnoresPlacemen - (MGLStyleValue *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextIgnorePlacement() ?: self.rawLayer->getDefaultTextIgnorePlacement(); + auto propertyValue = self.rawLayer->getTextIgnorePlacement(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextIgnorePlacement()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -618,7 +687,10 @@ - (void)setTextJustification:(MGLStyleValue *)textJustification { - (MGLStyleValue *)textJustification { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextJustify() ?: self.rawLayer->getDefaultTextJustify(); + auto propertyValue = self.rawLayer->getTextJustify(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultTextJustify()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -641,7 +713,10 @@ - (void)setTextLetterSpacing:(MGLStyleValue *)textLetterSpacing { - (MGLStyleValue *)textLetterSpacing { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextLetterSpacing() ?: self.rawLayer->getDefaultTextLetterSpacing(); + auto propertyValue = self.rawLayer->getTextLetterSpacing(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextLetterSpacing()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -655,7 +730,10 @@ - (void)setTextLineHeight:(MGLStyleValue *)textLineHeight { - (MGLStyleValue *)textLineHeight { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextLineHeight() ?: self.rawLayer->getDefaultTextLineHeight(); + auto propertyValue = self.rawLayer->getTextLineHeight(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextLineHeight()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -669,7 +747,10 @@ - (void)setTextOffset:(MGLStyleValue *)textOffset { - (MGLStyleValue *)textOffset { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextOffset() ?: self.rawLayer->getDefaultTextOffset(); + auto propertyValue = self.rawLayer->getTextOffset(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultTextOffset()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -683,7 +764,10 @@ - (void)setTextOptional:(MGLStyleValue *)textOptional { - (MGLStyleValue *)isTextOptional { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextOptional() ?: self.rawLayer->getDefaultTextOptional(); + auto propertyValue = self.rawLayer->getTextOptional(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextOptional()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -697,7 +781,10 @@ - (void)setTextPadding:(MGLStyleValue *)textPadding { - (MGLStyleValue *)textPadding { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextPadding() ?: self.rawLayer->getDefaultTextPadding(); + auto propertyValue = self.rawLayer->getTextPadding(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextPadding()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -711,7 +798,10 @@ - (void)setTextPitchAlignment:(MGLStyleValue *)textPitchAlignment { - (MGLStyleValue *)textPitchAlignment { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextPitchAlignment() ?: self.rawLayer->getDefaultTextPitchAlignment(); + auto propertyValue = self.rawLayer->getTextPitchAlignment(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultTextPitchAlignment()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -725,7 +815,10 @@ - (void)setTextRotation:(MGLStyleValue *)textRotation { - (MGLStyleValue *)textRotation { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextRotate() ?: self.rawLayer->getDefaultTextRotate(); + auto propertyValue = self.rawLayer->getTextRotate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextRotate()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -748,7 +841,10 @@ - (void)setTextRotationAlignment:(MGLStyleValue *)textRotationAlignme - (MGLStyleValue *)textRotationAlignment { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextRotationAlignment() ?: self.rawLayer->getDefaultTextRotationAlignment(); + auto propertyValue = self.rawLayer->getTextRotationAlignment(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultTextRotationAlignment()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -762,7 +858,10 @@ - (void)setTextSize:(MGLStyleValue *)textSize { - (MGLStyleValue *)textSize { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextSize() ?: self.rawLayer->getDefaultTextSize(); + auto propertyValue = self.rawLayer->getTextSize(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextSize()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -776,7 +875,10 @@ - (void)setTextTransform:(MGLStyleValue *)textTransform { - (MGLStyleValue *)textTransform { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextTransform() ?: self.rawLayer->getDefaultTextTransform(); + auto propertyValue = self.rawLayer->getTextTransform(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultTextTransform()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -792,7 +894,10 @@ - (void)setIconColor:(MGLStyleValue *)iconColor { - (MGLStyleValue *)iconColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconColor() ?: self.rawLayer->getDefaultIconColor(); + auto propertyValue = self.rawLayer->getIconColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconColor()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -806,7 +911,10 @@ - (void)setIconHaloBlur:(MGLStyleValue *)iconHaloBlur { - (MGLStyleValue *)iconHaloBlur { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconHaloBlur() ?: self.rawLayer->getDefaultIconHaloBlur(); + auto propertyValue = self.rawLayer->getIconHaloBlur(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconHaloBlur()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -820,7 +928,10 @@ - (void)setIconHaloColor:(MGLStyleValue *)iconHaloColor { - (MGLStyleValue *)iconHaloColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconHaloColor() ?: self.rawLayer->getDefaultIconHaloColor(); + auto propertyValue = self.rawLayer->getIconHaloColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconHaloColor()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -834,7 +945,10 @@ - (void)setIconHaloWidth:(MGLStyleValue *)iconHaloWidth { - (MGLStyleValue *)iconHaloWidth { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconHaloWidth() ?: self.rawLayer->getDefaultIconHaloWidth(); + auto propertyValue = self.rawLayer->getIconHaloWidth(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconHaloWidth()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -848,7 +962,10 @@ - (void)setIconOpacity:(MGLStyleValue *)iconOpacity { - (MGLStyleValue *)iconOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconOpacity() ?: self.rawLayer->getDefaultIconOpacity(); + auto propertyValue = self.rawLayer->getIconOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultIconOpacity()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -862,7 +979,10 @@ - (void)setIconTranslate:(MGLStyleValue *)iconTranslate { - (MGLStyleValue *)iconTranslate { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconTranslate() ?: self.rawLayer->getDefaultIconTranslate(); + auto propertyValue = self.rawLayer->getIconTranslate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultIconTranslate()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -871,12 +991,16 @@ - (void)setIconTranslateAnchor:(MGLStyleValue *)iconTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(iconTranslateAnchor); self.rawLayer->setIconTranslateAnchor(mbglValue); + self.rawLayer->setIconTranslateAnchor(mbglValue); } - (MGLStyleValue *)iconTranslateAnchor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getIconTranslateAnchor() ?: self.rawLayer->getDefaultIconTranslateAnchor(); + auto propertyValue = self.rawLayer->getIconTranslateAnchor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultIconTranslateAnchor()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } @@ -890,7 +1014,10 @@ - (void)setTextColor:(MGLStyleValue *)textColor { - (MGLStyleValue *)textColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextColor() ?: self.rawLayer->getDefaultTextColor(); + auto propertyValue = self.rawLayer->getTextColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextColor()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -904,7 +1031,10 @@ - (void)setTextHaloBlur:(MGLStyleValue *)textHaloBlur { - (MGLStyleValue *)textHaloBlur { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextHaloBlur() ?: self.rawLayer->getDefaultTextHaloBlur(); + auto propertyValue = self.rawLayer->getTextHaloBlur(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextHaloBlur()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -918,7 +1048,10 @@ - (void)setTextHaloColor:(MGLStyleValue *)textHaloColor { - (MGLStyleValue *)textHaloColor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextHaloColor() ?: self.rawLayer->getDefaultTextHaloColor(); + auto propertyValue = self.rawLayer->getTextHaloColor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextHaloColor()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -932,7 +1065,10 @@ - (void)setTextHaloWidth:(MGLStyleValue *)textHaloWidth { - (MGLStyleValue *)textHaloWidth { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextHaloWidth() ?: self.rawLayer->getDefaultTextHaloWidth(); + auto propertyValue = self.rawLayer->getTextHaloWidth(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextHaloWidth()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -946,7 +1082,10 @@ - (void)setTextOpacity:(MGLStyleValue *)textOpacity { - (MGLStyleValue *)textOpacity { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextOpacity() ?: self.rawLayer->getDefaultTextOpacity(); + auto propertyValue = self.rawLayer->getTextOpacity(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toStyleValue(self.rawLayer->getDefaultTextOpacity()); + } return MGLStyleValueTransformer().toStyleValue(propertyValue); } @@ -960,7 +1099,10 @@ - (void)setTextTranslate:(MGLStyleValue *)textTranslate { - (MGLStyleValue *)textTranslate { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextTranslate() ?: self.rawLayer->getDefaultTextTranslate(); + auto propertyValue = self.rawLayer->getTextTranslate(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer, NSValue *>().toStyleValue(self.rawLayer->getDefaultTextTranslate()); + } return MGLStyleValueTransformer, NSValue *>().toStyleValue(propertyValue); } @@ -969,14 +1111,18 @@ - (void)setTextTranslateAnchor:(MGLStyleValue *)textTranslateAnchor { auto mbglValue = MGLStyleValueTransformer().toEnumPropertyValue(textTranslateAnchor); self.rawLayer->setTextTranslateAnchor(mbglValue); + self.rawLayer->setTextTranslateAnchor(mbglValue); } - (MGLStyleValue *)textTranslateAnchor { MGLAssertStyleLayerIsValid(); - auto propertyValue = self.rawLayer->getTextTranslateAnchor() ?: self.rawLayer->getDefaultTextTranslateAnchor(); + auto propertyValue = self.rawLayer->getTextTranslateAnchor(); + if (propertyValue.isUndefined()) { + return MGLStyleValueTransformer().toEnumStyleValue(self.rawLayer->getDefaultTextTranslateAnchor()); + } return MGLStyleValueTransformer().toEnumStyleValue(propertyValue); } -@end +@end \ No newline at end of file diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 05c2f916956..80c3ffc8eb9 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -189,6 +189,10 @@ - (void)viewDidLoad } [self presentViewController:alertController animated:YES completion:nil]; } + + // Temp + NSURL *url = [[NSURL alloc] initWithString:@"mapbox://styles/boundsj/ciws3kslm00n82qqou2hnrow9"]; + [self.mapView setStyleURL:url]; } - (void)saveState:(__unused NSNotification *)notification @@ -791,7 +795,7 @@ - (void)styleSymbolLayer - (void)styleBuildingLayer { MGLFillStyleLayer *buildingLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"building"]; - buildingLayer.fillColor = [MGLStyleValue valueWithRawValue:[UIColor blackColor]]; + buildingLayer.fillColor = [MGLStyleValue valueWithRawValue:[UIColor purpleColor]]; } - (void)styleFerryLayer @@ -1638,4 +1642,72 @@ - (void)mapViewRegionIsChanging:(MGLMapView *)mapView } } + +#warning remove this test implementation + +- (void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView +{ + MGLCircleStyleLayer *circleLayer = (MGLCircleStyleLayer *)[self.mapView.style layerWithIdentifier:@"rgb-7q5w7f"]; + + // Data driven, constant ✔︎ +// circleLayer.circleColor = [MGLStyleValue valueWithRawValue:[UIColor greenColor]]; + + // Data driven, camera exponential ✔︎ + // circleLayer.circleColor = [MGLStyleValue valueWithBase:1.0 + // stops:@{ @0.0: [MGLStyleValue valueWithRawValue:[UIColor redColor]], + // @10.0: [MGLStyleValue valueWithRawValue:[UIColor redColor]], + // @15.0: [MGLStyleValue valueWithRawValue:[UIColor greenColor]] }]; + + // Data driven, camera interval ✔︎ + // circleLayer.circleColor = [MGLStyleValue valueWithIntervalStops:@{ @0.0: [MGLStyleValue valueWithRawValue:[UIColor redColor]], + // @12.0: [MGLStyleValue valueWithRawValue:[UIColor greenColor]], + // @18.0: [MGLStyleValue valueWithRawValue:[UIColor blueColor]] }]; + + // Data driven, source, categorical with string attribute key and default ✔︎ + // circleLayer.circleColor = [MGLStyleValue valueWithAttributeName:@"color" + // categoricalStops:@{ @"red": [MGLStyleValue valueWithRawValue:[UIColor redColor]]} + // defaultValue:[MGLStyleValue valueWithRawValue:[UIColor yellowColor]]]; + + // Data driven, source, categorical with integer attribute key ✔︎ +// circleLayer.circleColor = [MGLStyleValue valueWithAttributeName:@"temp" +// categoricalStops:@{ [NSNumber numberWithInt:0]: [MGLStyleValue valueWithRawValue:[UIColor greenColor]], +// [NSNumber numberWithInt:100]: [MGLStyleValue valueWithRawValue:[UIColor orangeColor]] } +// defaultValue:nil]; + + // Data driven, source, categorical with bool attribute key ✔︎ + // circleLayer.circleBlur = [MGLStyleValue valueWithAttributeName:@"fuzzy" + // categoricalStops:@{ [NSNumber numberWithBool:@NO]: [MGLStyleValue valueWithRawValue:[NSNumber numberWithDouble:2.0]], + // [NSNumber numberWithBool:@YES]: [MGLStyleValue valueWithRawValue:[NSNumber numberWithDouble:2.0]] } + // defaultValue:nil]; + + + // Data driven, source exponential (compiles and runs but it causes circles to not be drawn) ✖︎ + // circleLayer.circleColor = [MGLStyleValue valueWithAttributeName:@"special" exponentialStops:@{ @0.0: [MGLStyleValue valueWithRawValue:[UIColor redColor]], + // @15.0: [MGLStyleValue valueWithRawValue:[UIColor greenColor]] }]; + + + // Data driven, source interval (compiles and runs but it causes circles to not be drawn) ✖︎ + // circleLayer.circleColor = [MGLStyleValue valueWithAttributeName:@"special" intervalStops: @{ @0.0: [MGLStyleValue valueWithRawValue:[UIColor redColor]], + // @12.0: [MGLStyleValue valueWithRawValue:[UIColor greenColor]], + // @18.0: [MGLStyleValue valueWithRawValue:[UIColor blueColor]] }]; + + // Data driven, source identity for both number and color ✔︎ + // circleLayer.circleRadius = [MGLStyleValue valueWithAttributeName:@"size"]; + // circleLayer.circleColor = [MGLStyleValue valueWithAttributeName:@"hexColor"]; + + // a composite function that specifies that, at zoom level 0 - 8 the "red" attribute means the shape should be red and at zoom level 10 the "red" attribute means the shape should be blue. The default color will be yellow. ✔︎ +// NSDictionary *compositeStops = @{ [NSNumber numberWithInt:0]: [MGLStyleValue valueWithAttributeName:@"color" +// categoricalStops:@{@"red": [MGLStyleValue valueWithRawValue:[UIColor redColor]]} +// defaultValue:[MGLStyleValue valueWithRawValue:[UIColor yellowColor]]], +// [NSNumber numberWithInt:8]: [MGLStyleValue valueWithAttributeName:@"color" +// categoricalStops:@{@"red": [MGLStyleValue valueWithRawValue:[UIColor redColor]]} +// defaultValue:[MGLStyleValue valueWithRawValue:[UIColor yellowColor]]], +// [NSNumber numberWithInt:10]: [MGLStyleValue valueWithAttributeName:@"color" +// categoricalStops:@{@"red": [MGLStyleValue valueWithRawValue:[UIColor blueColor]]} +// defaultValue:[MGLStyleValue valueWithRawValue:[UIColor yellowColor]]], +// }; + +// circleLayer.circleColor = [MGLStyleValue valueWithAttributeName:@"color" compositeCategoricalStops:compositeStops]; +} + @end diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 6f2ee38e945..1af961becc8 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -896,8 +896,8 @@ DA72620A1DEEE3480043BB89 /* MGLOpenGLStyleLayer.mm */, 353933FA1D3FB7C0003F57D7 /* MGLRasterStyleLayer.h */, 35136D411D42274500C20EFD /* MGLRasterStyleLayer.mm */, - 35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */, 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */, + 35D13AB51D3D15E300AFB4E0 /* MGLStyleLayer.h */, 35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */, 353933FD1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h */, 35136D441D42275100C20EFD /* MGLSymbolStyleLayer.mm */, @@ -947,16 +947,16 @@ 3575798F1D513EF1000B822E /* Layers */ = { isa = PBXGroup; children = ( - DA2DBBCC1D51E80400D38FF9 /* MGLStyleLayerTests.h */, - DA2DBBCD1D51E80400D38FF9 /* MGLStyleLayerTests.m */, + 3575798A1D502B0C000B822E /* MGLBackgroundStyleLayerTests.m */, + 357579881D502B06000B822E /* MGLCircleStyleLayerTests.m */, 3575797F1D501E09000B822E /* MGLFillStyleLayerTests.m */, - 357579821D502AE6000B822E /* MGLRasterStyleLayerTests.m */, - 357579841D502AF5000B822E /* MGLSymbolStyleLayerTests.m */, 357579861D502AFE000B822E /* MGLLineStyleLayerTests.m */, - 357579881D502B06000B822E /* MGLCircleStyleLayerTests.m */, - 3575798A1D502B0C000B822E /* MGLBackgroundStyleLayerTests.m */, + 357579821D502AE6000B822E /* MGLRasterStyleLayerTests.m */, 3575798C1D502EC7000B822E /* MGLRuntimeStylingHelper.h */, 3575798D1D502EC7000B822E /* MGLRuntimeStylingHelper.m */, + DA2DBBCC1D51E80400D38FF9 /* MGLStyleLayerTests.h */, + DA2DBBCD1D51E80400D38FF9 /* MGLStyleLayerTests.m */, + 357579841D502AF5000B822E /* MGLSymbolStyleLayerTests.m */, ); name = Layers; sourceTree = "";