summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-09-27 18:05:26 -0700
committerjmkiley <jordan.kiley@mapbox.com>2019-09-27 18:05:26 -0700
commitb9d4e1a2a36bb6ff9f5fe05b2826ab2876b0b1e6 (patch)
tree40a0b66b1eae2b6ba0839b4b64211bd1ab730fa1
parent98f34197181dcc63a6abde811dc950bfead723b5 (diff)
downloadqtlocation-mapboxgl-b9d4e1a2a36bb6ff9f5fe05b2826ab2876b0b1e6.tar.gz
[ios] Address Fabian's feedback
-rw-r--r--platform/darwin/src/MGLShapeSource.h8
-rw-r--r--platform/darwin/src/MGLShapeSource.mm6
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.mm6
3 files changed, 8 insertions, 12 deletions
diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h
index 8eb581dae1..967fb94544 100644
--- a/platform/darwin/src/MGLShapeSource.h
+++ b/platform/darwin/src/MGLShapeSource.h
@@ -42,12 +42,12 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionClus
FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionClusterRadius;
/**
- An `NSDictionary` object where the key is an `NSString`. The dictionary key will be the attribute feature attribute key. The resulting attribute value is aggregated from the clustered points.
+ An `NSDictionary` object where the key is an `NSString`. The dictionary key will be the attribute feature attribute key. The resulting attribute value is aggregated from the clustered points. The dictionary value is an `NSArray` consisting of a reduce operator and a map expression.
- The dictionary key is an `NSString` that will be an attribute key for the clusters. The dictionary value is an `NSArray` consisting of a reduce operator and a map expression.
+ The reduce operator is any `NSExpression` function that accepts at least two operands. You can use one of the following:
- The reduce operator is any `NSExpression` function that accepts at least two operands. It can be a string containing a single function, such as `sum:`, or a valid expression with two expression arguments: `featureAccumulated` and
- another valid expression.
+ * An `NSString` containing a single function, such as `sum` or `max`.
+ * An `NSExpression` that takes two expression arguments: `featureAccumulated` and another valid expression.
The map expression is an `NSExpression` that produces the value of a single point within the cluster.
diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm
index b806987267..00641c4a93 100644
--- a/platform/darwin/src/MGLShapeSource.mm
+++ b/platform/darwin/src/MGLShapeSource.mm
@@ -99,9 +99,9 @@ mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary<MGLShap
NSArray *expressionsArray = value[key];
if (![expressionsArray isKindOfClass:[NSArray class]]) {
[NSException raise:NSInvalidArgumentException
- format:@"MGLShapeSourceOptionClusterProperties dictinary member value must be an array containing two objects."];
+ format:@"MGLShapeSourceOptionClusterProperties dictionary member value must be an array containing two objects."];
}
- // check that array has only 2 values
+ // Check that the array has 2 values. One should be a the reduce expression and one should be the map expression.
if ([expressionsArray count] != 2) {
[NSException raise:NSInvalidArgumentException
format:@"MGLShapeSourceOptionClusterProperties member value requires array of two objects."];
@@ -132,7 +132,7 @@ mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary<MGLShap
NSExpression *mapExpression = expressionsArray[1];
if (![mapExpression isKindOfClass:[NSExpression class]]) {
[NSException raise:NSInvalidArgumentException
- format:@"MGLShapeSourceOptionClusterProperties member value shall contain a valid mapExpression.."];
+ format:@"MGLShapeSourceOptionClusterProperties member value shall contain a valid mapExpression."];
}
auto map = MGLClusterPropertyFromNSExpression(mapExpression);
if (!map) {
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm
index 93729f1bdf..9bbea4fa34 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.mm
+++ b/platform/darwin/src/NSExpression+MGLAdditions.mm
@@ -652,7 +652,6 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
@"let": @"MGL_LET",
};
});
-
if (!object || object == [NSNull null]) {
return [NSExpression expressionForConstantValue:nil];
}
@@ -671,7 +670,6 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
}];
return [NSExpression expressionForConstantValue:dictionary];
}
-
if ([object isKindOfClass:[NSArray class]]) {
NSArray *array = (NSArray *)object;
NSString *op = array.firstObject;
@@ -1056,9 +1054,7 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
case NSFunctionExpressionType: {
NSString *function = self.function;
- BOOL hasCollectionProperty = !( ! [self.arguments.firstObject isKindOfClass: [NSExpression class]] || self.arguments.firstObject.expressionType == NSConstantValueExpressionType || self.arguments.firstObject.expressionType == NSKeyPathExpressionType
- || self.arguments.firstObject.expressionType == NSVariableExpressionType
- );
+ BOOL hasCollectionProperty = !( ! [self.arguments.firstObject isKindOfClass: [NSExpression class]] || self.arguments.firstObject.expressionType != NSAggregateExpressionType || self.arguments.firstObject.expressionType == NSSubqueryExpressionType);
NSString *op = MGLExpressionOperatorsByFunctionNames[function];
if (op) {
NSArray *arguments = self.arguments.mgl_jsonExpressionObject;