From 96db1c0ec991c2bbef78bc7b3a0ea5e1fe7d86a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 25 Oct 2018 04:41:34 -0700 Subject: [PATCH 1/2] [ios, macos] Fixed typo in style authors guide --- platform/darwin/docs/guides/For Style Authors.md.ejs | 2 +- platform/ios/docs/guides/For Style Authors.md | 2 +- platform/macos/docs/guides/For Style Authors.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs index 0ae95975d82..51fc10d8747 100644 --- a/platform/darwin/docs/guides/For Style Authors.md.ejs +++ b/platform/darwin/docs/guides/For Style Authors.md.ejs @@ -400,7 +400,7 @@ In style specification | Method, function, or predicate type | Format string syn `sin` | `mgl_sin:` | `mgl_sin(0)` `sqrt` | `sqrt:` | `sqrt(2)` `tan` | `mgl_tan:` | `mgl_tan(0)` -`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoom` +`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` `heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` For operators that have no corresponding `NSExpression` symbol, use the diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index b0351060f39..b2ebd0de86e 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -386,7 +386,7 @@ In style specification | Method, function, or predicate type | Format string syn `sin` | `mgl_sin:` | `mgl_sin(0)` `sqrt` | `sqrt:` | `sqrt(2)` `tan` | `mgl_tan:` | `mgl_tan(0)` -`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoom` +`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` `heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` For operators that have no corresponding `NSExpression` symbol, use the diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md index 273381eb7e0..49b96fb48b9 100644 --- a/platform/macos/docs/guides/For Style Authors.md +++ b/platform/macos/docs/guides/For Style Authors.md @@ -379,7 +379,7 @@ In style specification | Method, function, or predicate type | Format string syn `sin` | `mgl_sin:` | `mgl_sin(0)` `sqrt` | `sqrt:` | `sqrt(2)` `tan` | `mgl_tan:` | `mgl_tan(0)` -`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoom` +`zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` `heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` For operators that have no corresponding `NSExpression` symbol, use the From 796256c5e2566cb8095c67523243b8555c637e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Thu, 25 Oct 2018 04:57:08 -0700 Subject: [PATCH 2/2] [ios, macos] Added $lineProgress expression variable --- platform/darwin/docs/guides/For Style Authors.md.ejs | 1 + .../darwin/docs/guides/Predicates and Expressions.md | 11 +++++++++++ platform/darwin/src/NSExpression+MGLAdditions.h | 7 +++++++ platform/darwin/src/NSExpression+MGLAdditions.mm | 9 +++++++++ platform/darwin/test/MGLExpressionTests.mm | 8 ++++++++ platform/ios/CHANGELOG.md | 1 + platform/ios/docs/guides/For Style Authors.md | 1 + platform/macos/CHANGELOG.md | 1 + platform/macos/docs/guides/For Style Authors.md | 1 + 9 files changed, 40 insertions(+) diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs index 51fc10d8747..ead3b81ce6e 100644 --- a/platform/darwin/docs/guides/For Style Authors.md.ejs +++ b/platform/darwin/docs/guides/For Style Authors.md.ejs @@ -402,6 +402,7 @@ In style specification | Method, function, or predicate type | Format string syn `tan` | `mgl_tan:` | `mgl_tan(0)` `zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` `heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` +`line-progress` | `NSExpression.lineProgressVariableExpression` | `$lineProgress` For operators that have no corresponding `NSExpression` symbol, use the `MGL_FUNCTION()` format string syntax. diff --git a/platform/darwin/docs/guides/Predicates and Expressions.md b/platform/darwin/docs/guides/Predicates and Expressions.md index 90f010e9549..c70d76b5816 100644 --- a/platform/darwin/docs/guides/Predicates and Expressions.md +++ b/platform/darwin/docs/guides/Predicates and Expressions.md @@ -290,6 +290,17 @@ The following variables are defined by this SDK for use with style layers: NSExpression.zoomLevelVariableExpression property. + + $lineProgress + Number + + A number that indicates the relative distance along a line at a given + point along the line. This variable evaluates to 0 at the beginning of the + line and 1 at the end of the line. It can only be used with the + `MGLLineStyleLayer.lineGradient` property. It corresponds to the + NSExpression.lineProgressVariableExpression property. + + diff --git a/platform/darwin/src/NSExpression+MGLAdditions.h b/platform/darwin/src/NSExpression+MGLAdditions.h index d13f0227b46..9ee73614481 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.h +++ b/platform/darwin/src/NSExpression+MGLAdditions.h @@ -61,6 +61,13 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionI */ @property (class, nonatomic, readonly) NSExpression *heatmapDensityVariableExpression; +/** + `NSExpression` variable that corresponds to the + line-progress + expression operator in the Mapbox Style Specification. + */ +@property (class, nonatomic, readonly) NSExpression *lineProgressVariableExpression; + /** `NSExpression` variable that corresponds to the geometry-type diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index cb7f30f65a8..9c12c6beaca 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -542,6 +542,10 @@ + (NSExpression *)heatmapDensityVariableExpression { return [NSExpression expressionForVariable:@"heatmapDensity"]; } ++ (NSExpression *)lineProgressVariableExpression { + return [NSExpression expressionForVariable:@"lineProgress"]; +} + + (NSExpression *)geometryTypeVariableExpression { return [NSExpression expressionForVariable:@"geometryType"]; } @@ -814,6 +818,8 @@ + (instancetype)expressionWithMGLJSONObject:(id)object { return NSExpression.zoomLevelVariableExpression; } else if ([op isEqualToString:@"heatmap-density"]) { return NSExpression.heatmapDensityVariableExpression; + } else if ([op isEqualToString:@"line-progress"]) { + return NSExpression.lineProgressVariableExpression; } else if ([op isEqualToString:@"geometry-type"]) { return NSExpression.geometryTypeVariableExpression; } else if ([op isEqualToString:@"id"]) { @@ -911,6 +917,9 @@ - (id)mgl_jsonExpressionObject { if ([self.variable isEqualToString:@"heatmapDensity"]) { return @[@"heatmap-density"]; } + if ([self.variable isEqualToString:@"lineProgress"]) { + return @[@"line-progress"]; + } if ([self.variable isEqualToString:@"zoomLevel"]) { return @[@"zoom"]; } diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index 1b0630cef38..8856cbf5288 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -170,6 +170,14 @@ - (void)testVariableExpressionObject { NSMutableDictionary *context = [@{@"heatmapDensity": @1} mutableCopy]; XCTAssertEqualObjects([expression expressionValueWithObject:nil context:context], @1); } + { + NSExpression *expression = [NSExpression expressionForVariable:@"lineProgress"]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"line-progress"]); + XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$lineProgress"].mgl_jsonExpressionObject, @[@"line-progress"]); + XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"line-progress"]], expression); + NSMutableDictionary *context = [@{@"lineProgress": @1} mutableCopy]; + XCTAssertEqualObjects([expression expressionValueWithObject:nil context:context], @1); + } { NSExpression *expression = [NSExpression expressionForVariable:@"geometryType"]; XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"geometry-type"]); diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index b37087d1895..47feef842e3 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -8,6 +8,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Added the ability to style symbol layers labels with multiple fonts and text sizes via the `format` expression operator. ([#12624](https://github.com/mapbox/mapbox-gl-native/pull/12624)) * Fixed a crash when using the `MGL_LET`, `MGL_MATCH`, `MGL_IF`, or `MGL_FUNCTION` functions without a colon inside an `NSExpression` or `NSPredicate` format string. ([#13189](https://github.com/mapbox/mapbox-gl-native/pull/13189)) +* Fixed a crash setting the `MGLLineStyleLayer.lineGradient` property to an expression containing the `$lineProgress` variable. Added an `NSExpression.lineProgressVariableExpression` class property that returns an expression for the `$lineProgress` variable. ([#13192](https://github.com/mapbox/mapbox-gl-native/pull/13192)) ### Offline maps diff --git a/platform/ios/docs/guides/For Style Authors.md b/platform/ios/docs/guides/For Style Authors.md index b2ebd0de86e..23766e696ad 100644 --- a/platform/ios/docs/guides/For Style Authors.md +++ b/platform/ios/docs/guides/For Style Authors.md @@ -388,6 +388,7 @@ In style specification | Method, function, or predicate type | Format string syn `tan` | `mgl_tan:` | `mgl_tan(0)` `zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` `heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` +`line-progress` | `NSExpression.lineProgressVariableExpression` | `$lineProgress` For operators that have no corresponding `NSExpression` symbol, use the `MGL_FUNCTION()` format string syntax. diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index d9c70cb24a4..b0179eb6fef 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -7,6 +7,7 @@ * Added an `MGLSymbolStyleLayer.symbolZOrder` property for forcing point features in a symbol layer to be layered in the same order that they are specified in the layer’s associated source. ([#12783](https://github.com/mapbox/mapbox-gl-native/pull/12783)) * Fixed a crash when a style layer `*-pattern` property evaluates to nil for a particular feature. ([#12896](https://github.com/mapbox/mapbox-gl-native/pull/12896)) * Fixed a crash when using the `MGL_LET`, `MGL_MATCH`, `MGL_IF`, or `MGL_FUNCTION` functions without a colon inside an `NSExpression` or `NSPredicate` format string. ([#13189](https://github.com/mapbox/mapbox-gl-native/pull/13189)) +* Fixed a crash setting the `MGLLineStyleLayer.lineGradient` property to an expression containing the `$lineProgress` variable. Added an `NSExpression.lineProgressVariableExpression` class property that returns an expression for the `$lineProgress` variable. ([#13192](https://github.com/mapbox/mapbox-gl-native/pull/13192)) * Fixed an issue where fill and line layers would occasionally flicker on zoom ([#12982](https://github.com/mapbox/mapbox-gl-native/pull/12982)) ### Offline maps diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md index 49b96fb48b9..5c34c857b20 100644 --- a/platform/macos/docs/guides/For Style Authors.md +++ b/platform/macos/docs/guides/For Style Authors.md @@ -381,6 +381,7 @@ In style specification | Method, function, or predicate type | Format string syn `tan` | `mgl_tan:` | `mgl_tan(0)` `zoom` | `NSExpression.zoomLevelVariableExpression` | `$zoomLevel` `heatmap-density` | `NSExpression.heatmapDensityVariableExpression` | `$heatmapDensity` +`line-progress` | `NSExpression.lineProgressVariableExpression` | `$lineProgress` For operators that have no corresponding `NSExpression` symbol, use the `MGL_FUNCTION()` format string syntax.