diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-09-21 09:12:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-21 09:12:59 -0700 |
commit | 1165a408fbee37a0892b07b5c35e1a36d7aa0063 (patch) | |
tree | 5ee4aa50d79ba712cf744af44255cb3490c92513 /platform/darwin/src/NSPredicate+MGLAdditions.mm | |
parent | 6fe621bbef43e6b73a53ca25a9df3d349cd84929 (diff) | |
download | qtlocation-mapboxgl-1165a408fbee37a0892b07b5c35e1a36d7aa0063.tar.gz |
[ios, macos] Add more predicate operator to mbgl filter translations
Adds several new translations to prevent data loss.
Diffstat (limited to 'platform/darwin/src/NSPredicate+MGLAdditions.mm')
-rw-r--r-- | platform/darwin/src/NSPredicate+MGLAdditions.mm | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/platform/darwin/src/NSPredicate+MGLAdditions.mm b/platform/darwin/src/NSPredicate+MGLAdditions.mm index 9c3f9c888c..64ad277e4d 100644 --- a/platform/darwin/src/NSPredicate+MGLAdditions.mm +++ b/platform/darwin/src/NSPredicate+MGLAdditions.mm @@ -76,15 +76,11 @@ public: } NSPredicate* operator()(mbgl::style::HasFilter filter) { - [NSException raise:@"Unsupported filter type" - format:@"Cannot convert mbgl::style::HasFilter to NSPredicate"]; - return nil; + return [NSPredicate predicateWithFormat:@"%K != nil", @(filter.key.c_str())]; } NSPredicate* operator()(mbgl::style::NotHasFilter filter) { - [NSException raise:@"Unsupported filter type" - format:@"Cannot convert mbgl::style::NotHasFilter to NSPredicate"]; - return nil; + return [NSPredicate predicateWithFormat:@"%K == nil", @(filter.key.c_str())]; } }; @@ -93,8 +89,20 @@ public: - (mbgl::style::Filter)mgl_filter { + if ([self isEqual:[NSPredicate predicateWithValue:YES]]) + { + auto filter = mbgl::style::AllFilter(); + return filter; + } + + if ([self isEqual:[NSPredicate predicateWithValue:NO]]) + { + auto filter = mbgl::style::AnyFilter(); + return filter; + } + [NSException raise:@"Not supported" - format:@"NSPredicate doesn't implement ’-mgl_filter’. Try with NSComparisonPredicate or NSCompoundPredicate instead."]; + format:@"Try with NSComparisonPredicate or NSCompoundPredicate instead."]; return {}; } |