summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/docs/guides/For Style Authors.md.ejs1
-rw-r--r--platform/darwin/docs/guides/Predicates and Expressions.md11
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.h7
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.mm9
-rw-r--r--platform/darwin/test/MGLExpressionTests.mm8
5 files changed, 36 insertions, 0 deletions
diff --git a/platform/darwin/docs/guides/For Style Authors.md.ejs b/platform/darwin/docs/guides/For Style Authors.md.ejs
index 51fc10d874..ead3b81ce6 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 90f010e954..c70d76b581 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:
<code>NSExpression.zoomLevelVariableExpression</code> property.
</td>
</tr>
+<tr>
+ <td><code>$lineProgress</code></td>
+ <td>Number</td>
+ <td>
+ 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
+ <code>NSExpression.lineProgressVariableExpression</code> property.
+ </td>
+</tr>
</tbody>
</table>
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.h b/platform/darwin/src/NSExpression+MGLAdditions.h
index d13f0227b4..9ee7361448 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.h
+++ b/platform/darwin/src/NSExpression+MGLAdditions.h
@@ -63,6 +63,13 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionI
/**
`NSExpression` variable that corresponds to the
+ <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-line-progress"><code>line-progress</code></a>
+ expression operator in the Mapbox Style Specification.
+ */
+@property (class, nonatomic, readonly) NSExpression *lineProgressVariableExpression;
+
+/**
+ `NSExpression` variable that corresponds to the
<a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#eexpressions-geometry-type"><code>geometry-type</code></a>
expression operator in the Mapbox Style Specification.
*/
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm
index cb7f30f65a..9c12c6beac 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.mm
+++ b/platform/darwin/src/NSExpression+MGLAdditions.mm
@@ -542,6 +542,10 @@ const MGLExpressionInterpolationMode MGLExpressionInterpolationModeCubicBezier =
return [NSExpression expressionForVariable:@"heatmapDensity"];
}
++ (NSExpression *)lineProgressVariableExpression {
+ return [NSExpression expressionForVariable:@"lineProgress"];
+}
+
+ (NSExpression *)geometryTypeVariableExpression {
return [NSExpression expressionForVariable:@"geometryType"];
}
@@ -814,6 +818,8 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
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 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
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 1b0630cef3..8856cbf528 100644
--- a/platform/darwin/test/MGLExpressionTests.mm
+++ b/platform/darwin/test/MGLExpressionTests.mm
@@ -171,6 +171,14 @@ using namespace std::string_literals;
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"]);
XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$geometryType"].mgl_jsonExpressionObject, @[@"geometry-type"]);