diff options
author | jmkiley <jordan.kiley@mapbox.com> | 2019-06-28 14:05:34 -0700 |
---|---|---|
committer | jmkiley <jordan.kiley@mapbox.com> | 2019-07-09 15:03:39 -0700 |
commit | b58e766ca68a41f582b85111c0eacd53a16ce341 (patch) | |
tree | c860b2a004f9216e8c1e792c753a589752344636 | |
parent | 495fe30146c70f85dda1f1a77462515cabb23546 (diff) | |
download | qtlocation-mapboxgl-b58e766ca68a41f582b85111c0eacd53a16ce341.tar.gz |
[ios] attempting invalidateOfflineRegionForPack: approach
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.mm | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 3e30c1f6ed..60b4dccba7 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -446,31 +446,47 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio } -- (void)invalidateOfflineRegion:(id <MGLOfflineRegion>)region withCompletionHandler:(void (^)(NSError * _Nullable))completion { - if (!completion) { return; } - - if (![region conformsToProtocol:@protocol(MGLOfflineRegion_Private)]) { - [NSException raise:MGLUnsupportedRegionTypeException - format:@"Regions of type %@ are unsupported.", NSStringFromClass([region class])]; - return; - } - -// const mbgl::OfflineRegionDefinition regionDefinition = [(id <MGLOfflineRegion_Private>)region offlineRegionDefinition]; -// _mbglFileSource->createOfflineRegion(regionDefinition, nil, [&, completion](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> mbglOfflineRegion) { -// }); -// // JK - I need to convert the MGLOfflineRegion to an OfflineRegion. :ohno: -// mbgl::OfflineRegion offlineRegion = const_cast<mbgl::OfflineRegion>(region); - MGLShapeOfflineRegion *weakCopy = region; - - _mbglFileSource->invalidateOfflineRegion(weakCopy, [&, completion](std::exception_ptr exception) { - NSError *error; - if (error) { +- (void)invalidateOfflineRegionForPack:(MGLOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion { + const mbgl::OfflineRegion *region = pack.mbglOfflineRegion; + const mbgl::OfflineRegion&& regionRef = &pack.mbglOfflineRegion; + NSError *error; + if (!region) { + completion(nil); + return; } + _mbglFileSource->invalidateOfflineRegion(regionRef, [&, completion](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> mbglOfflineRegion) { + if (mbglOfflineRegion) { error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{ - + }]; } }); + } +//- (void)invalidateOfflineRegion:(id <MGLOfflineRegion>)region withCompletionHandler:(void (^)(NSError * _Nullable))completion { +// if (!completion) { return; } +// +// if (![region conformsToProtocol:@protocol(MGLOfflineRegion_Private)]) { +// [NSException raise:MGLUnsupportedRegionTypeException +// format:@"Regions of type %@ are unsupported.", NSStringFromClass([region class])]; +// return; +// } +// +//// const mbgl::OfflineRegionDefinition regionDefinition = [(id <MGLOfflineRegion_Private>)region offlineRegionDefinition]; +//// _mbglFileSource->createOfflineRegion(regionDefinition, nil, [&, completion](mbgl::expected<mbgl::OfflineRegion, std::exception_ptr> mbglOfflineRegion) { +//// }); +//// // JK - I need to convert the MGLOfflineRegion to an OfflineRegion. :ohno: +//// mbgl::OfflineRegion offlineRegion = const_cast<mbgl::OfflineRegion>(region); +// MGLShapeOfflineRegion *weakCopy = region; +// +// _mbglFileSource->invalidateOfflineRegion(weakCopy, [&, completion](std::exception_ptr exception) { +// NSError *error; +// if (error) { +// error = [NSError errorWithDomain:MGLErrorDomain code:-1 userInfo:@{ +// +// }]; +// } +// }); +//} - (void)reloadPacks { MGLLogInfo(@"Reloading packs."); [self getPacksWithCompletionHandler:^(NSArray<MGLOfflinePack *> *packs, __unused NSError * _Nullable error) { |