summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Guerra <fabian.guerra@mapbox.com>2018-04-16 15:00:05 -0400
committerFabian Guerra <fabian.guerra@mapbox.com>2018-04-16 15:00:05 -0400
commit0dbfcd824871306a584bd345c004e65be259ff55 (patch)
tree4ba5aed49b6547342fa766d8e1746736175da3af
parent40fda88a16c283557d5f63ed22292929960bfec6 (diff)
downloadqtlocation-mapboxgl-0dbfcd824871306a584bd345c004e65be259ff55.tar.gz
[ios, macos] Update predicates and expressions documentation.
-rw-r--r--platform/darwin/docs/guides/Predicates and Expressions.md37
1 files changed, 14 insertions, 23 deletions
diff --git a/platform/darwin/docs/guides/Predicates and Expressions.md b/platform/darwin/docs/guides/Predicates and Expressions.md
index f054bee928..6b191720b7 100644
--- a/platform/darwin/docs/guides/Predicates and Expressions.md
+++ b/platform/darwin/docs/guides/Predicates and Expressions.md
@@ -19,17 +19,6 @@ based on the feature’s attributes. Use the `MGLVectorStyleLayer.predicate`
property to include only the features in the source layer that satisfy a
condition that you define.
-When a predicate is used for filtering vector data the key should be cast
-explicitly into the key's type. A number based key will become: `CAST(key, 'NSNumber')`
-
-`NSPredicateOperatorType` | Format string syntax
-----------------------------------------------|---------------------
-`NSGreaterThanOrEqualToPredicateOperatorType` | `CAST(key, 'valueType') >= value`<br />`CAST(key, 'valueType') => value`
-`NSLessThanOrEqualToPredicateOperatorType` | `CAST(key, 'valueType') <= value`<br />`CAST(key, 'valueType') =< value`
-`NSGreaterThanPredicateOperatorType` | `CAST(key, 'valueType') > value`
-`NSLessThanPredicateOperatorType` | `CAST(key, 'valueType') < value`
-
-
The following comparison operators are supported:
`NSPredicateOperatorType` | Format string syntax
@@ -42,6 +31,9 @@ The following comparison operators are supported:
`NSNotEqualToPredicateOperatorType` | `key != value`<br />`key <> value`
`NSBetweenPredicateOperatorType` | `key BETWEEN { 32, 212 }`
+The `key` may be cast explicitly into the key's type. Example: `CAST(key, 'NSNumber')` or
+`CAST(key, 'NSString')`
+
The following compound operators are supported:
`NSCompoundPredicateType` | Format string syntax
@@ -67,8 +59,11 @@ Format String Syntax” chapter of the
_[Predicate Programming Guide](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Predicates/AdditionalChapters/Introduction.html)_
in Apple developer documentation.
-The predicate's left-hand expression must be a string that identifies a feature
-attribute or, alternatively, one of the following special attributes:
+Either the predicate’s left-hand or right-hand expression can be an `NSString`
+(to match strings) or `NSNumber` (to match numbers, including Boolean values)
+or an array of `NSString`s or `NSNumber`s, depending on the operator and the
+type of values expected for the attribute being tested or, alternatively,
+one of the following special attributes:
<table>
<thead>
@@ -112,12 +107,8 @@ attribute or, alternatively, one of the following special attributes:
</tbody>
</table>
-The predicate’s right-hand expression must be an `NSString` (to match strings)
-or `NSNumber` (to match numbers, including Boolean values) or an array of
-`NSString`s or `NSNumber`s, depending on the operator and the type of values
-expected for the attribute being tested. For floating-point values, use
-`-[NSNumber numberWithDouble:]` instead of `-[NSNumber numberWithFloat:]`
-to avoid precision issues.
+For floating-point values, use `-[NSNumber numberWithDouble:]` instead of
+`-[NSNumber numberWithFloat:]` to avoid precision issues.
Automatic type casting is not performed. Therefore, a feature only matches this
predicate if its value for the attribute in question is of the same type as the
@@ -127,10 +118,10 @@ sensitivity) are unsupported for comparison and aggregate operators that are
used in the predicate.
It is possible to create expressions that contain special characters in the
-predicate format syntax. This includes the `$` in the `$id` and `$type` special
-style attributes and also `hyphen-minus` and `tag:subtag`. However, you must use
-`%K` in the format string to represent these variables:
-`@"%K == 'LineString'", @"$type"`.
+predicate format syntax. This includes the `$` in the `$featureIdentifier` and
+`$geometryType` special style attributes and also `hyphen-minus` and `tag:subtag`.
+However, you must use `%@` in the format string to represent these variables:
+`@"$geometryType == 'LineString'"`.
## Using expressions to configure layout and paint attributes