[ios, macos] Add back support for CONTAINS operator
This reverts commit 6877e3efe7.
This commit is contained in:
@@ -68,6 +68,12 @@
|
||||
filter.values = self.rightExpression.mgl_filterValues;
|
||||
return filter;
|
||||
}
|
||||
case NSContainsPredicateOperatorType: {
|
||||
auto filter = mbgl::style::InFilter();
|
||||
filter.key = [self.rightExpression.constantValue UTF8String];
|
||||
filter.values = self.leftExpression.mgl_filterValues;
|
||||
return filter;
|
||||
}
|
||||
case NSBetweenPredicateOperatorType: {
|
||||
auto filter = mbgl::style::AllFilter();
|
||||
auto gteFilter = mbgl::style::GreaterThanEqualsFilter();
|
||||
@@ -85,7 +91,6 @@
|
||||
case NSBeginsWithPredicateOperatorType:
|
||||
case NSEndsWithPredicateOperatorType:
|
||||
case NSCustomSelectorPredicateOperatorType:
|
||||
case NSContainsPredicateOperatorType:
|
||||
[NSException raise:@"Unsupported operator type"
|
||||
format:@"NSPredicateOperatorType:%lu is not supported.", (unsigned long)self.predicateOperatorType];
|
||||
}
|
||||
|
||||
@@ -74,6 +74,18 @@
|
||||
[self.mapView.style addLayer:layer];
|
||||
}
|
||||
|
||||
- (void)testContainsPredicate
|
||||
{
|
||||
// core does not have a "contains" filter but we can achieve the equivalent by creating an `mbgl::style::InFilter`
|
||||
// and searching the value for the key
|
||||
NSPredicate *expectedPredicate = [NSPredicate predicateWithFormat:@"park IN %@", @[@"park", @"neighbourhood"]];
|
||||
NSPredicate *containsPredicate = [NSPredicate predicateWithFormat:@"%@ CONTAINS %@", @[@"park", @"neighbourhood"], @"park"];
|
||||
|
||||
layer.predicate = containsPredicate;
|
||||
XCTAssertEqualObjects(layer.predicate, expectedPredicate);
|
||||
[self.mapView.style addLayer:layer];
|
||||
}
|
||||
|
||||
- (void)testBetweenPredicate
|
||||
{
|
||||
// core does not have a "between" filter but we can achieve the equivalent by creating a set of greater than or equal / less than or equal
|
||||
|
||||
Reference in New Issue
Block a user