summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmkiley <jordan.kiley@mapbox.com>2019-07-18 16:56:42 -0700
committerjmkiley <jordan.kiley@mapbox.com>2019-07-18 16:56:42 -0700
commit5656477af104817ed71a976835896f15f653f695 (patch)
tree7d443aaa24e4c29dd82f43a7f6046db56e76c962
parentbbea3d01c6035867d08b92973006eae4647df136 (diff)
downloadqtlocation-mapboxgl-5656477af104817ed71a976835896f15f653f695.tar.gz
[ios] Add example to debug menu
-rw-r--r--platform/ios/app/MBXViewController.m75
1 files changed, 72 insertions, 3 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
index 2fb95e1b17..ad2dce4e45 100644
--- a/platform/ios/app/MBXViewController.m
+++ b/platform/ios/app/MBXViewController.m
@@ -49,7 +49,10 @@ typedef NS_ENUM(NSInteger, MBXSettingsDebugToolsRows) {
MBXSettingsDebugToolsOverdrawVisualization,
MBXSettingsDebugToolsShowZoomLevel,
MBXSettingsDebugToolsShowFrameTimeGraph,
- MBXSettingsDebugToolsShowReuseQueueStats
+ MBXSettingsDebugToolsShowReuseQueueStats,
+ MBXSettingsDebugToolsInvalidateAmbientCache,
+ MBXSettingsDebugToolsClearAmbientCache,
+ MBXSettingsDebugToolsResetDatabase
};
typedef NS_ENUM(NSInteger, MBXSettingsAnnotationsRows) {
@@ -375,7 +378,10 @@ CLLocationCoordinate2D randomWorldCoordinate() {
(debugMask & MGLMapDebugOverdrawVisualizationMask ? @"Hide" :@"Show")],
[NSString stringWithFormat:@"%@ zoom level ornament", (self.zoomLevelOrnamentEnabled ? @"Hide" :@"Show")],
[NSString stringWithFormat:@"%@ frame time graph", (self.frameTimeGraphEnabled ? @"Hide" :@"Show")],
- [NSString stringWithFormat:@"%@ reuse queue stats", (self.reuseQueueStatsEnabled ? @"Hide" :@"Show")]
+ [NSString stringWithFormat:@"%@ reuse queue stats", (self.reuseQueueStatsEnabled ? @"Hide" :@"Show")],
+ @"Invalidate Ambient Cache",
+ @"Clear Ambient Cache",
+ @"Reset Database",
]];
break;
case MBXSettingsAnnotations:
@@ -508,11 +514,19 @@ CLLocationCoordinate2D randomWorldCoordinate() {
[self updateHUD];
break;
}
+ case MBXSettingsDebugToolsInvalidateAmbientCache:
+ [self invalidateAmbientCache];
+ break;
+ case MBXSettingsDebugToolsClearAmbientCache:
+ [self clearAmbientCache];
+ break;
+ case MBXSettingsDebugToolsResetDatabase:
+ [self resetDatabase];
+ break;
default:
NSAssert(NO, @"All debug tools setting rows should be implemented");
break;
}
-
self.mapView.debugMask = self.currentState.debugMask;
break;
@@ -1765,6 +1779,61 @@ CLLocationCoordinate2D randomWorldCoordinate() {
return filePath;
}
+#pragma mark:
+- (void)invalidateAmbientCache {
+ CFTimeInterval start = CACurrentMediaTime();
+ [[MGLOfflineStorage sharedOfflineStorage] invalidateAmbientCacheWithCompletionHandler:^(NSError * _Nullable error) {
+ if (error) {
+ NSLog(@"Error: %@", error.localizedDescription);
+ return;
+ } else {
+ CFTimeInterval difference = CACurrentMediaTime() - start;
+ NSLog(@"Ambient cache invalidated in %f seconds", difference);
+ }
+ }];
+}
+
+- (void)invalidateOfflinePack {
+ CFTimeInterval start = CACurrentMediaTime();
+ MGLOfflinePack *pack = [MGLOfflineStorage sharedOfflineStorage].packs.firstObject;
+
+ [[MGLOfflineStorage sharedOfflineStorage] invalidatePack:pack withCompletionHandler:^(NSError * _Nullable error) {
+ if (error) {
+ NSLog(@"Error: %@", error.localizedDescription);
+ return;
+ } else {
+ CFTimeInterval difference = CACurrentMediaTime() - start;
+ NSLog(@"Offline pack invalidated in %f seconds", difference);
+ }
+ }];
+}
+
+- (void)clearAmbientCache {
+ CFTimeInterval start = CACurrentMediaTime();
+ [[MGLOfflineStorage sharedOfflineStorage] clearAmbientCacheWithCompletionHandler:^(NSError * _Nullable error) {
+ if (error) {
+ NSLog(@"Error: %@", error.localizedDescription);
+ return;
+ } else {
+ CFTimeInterval difference = CACurrentMediaTime() - start;
+ NSLog(@"Ambient cache cleared in %f seconds", difference);
+ }
+ }];
+}
+
+- (void)resetDatabase {
+ CFTimeInterval start = CACurrentMediaTime();
+ [[MGLOfflineStorage sharedOfflineStorage] resetDatabaseWithCompletionHandler:^(NSError * _Nullable error) {
+ if (error) {
+ NSLog(@"Error: %@", error.localizedDescription);
+ return;
+ } else {
+ CFTimeInterval difference = CACurrentMediaTime() - start;
+ NSLog(@"Database reset in %f seconds", difference);
+ }
+ }];
+}
+
#pragma mark - Random World Tour
- (void)addAnnotations:(NSInteger)numAnnotations aroundCoordinate:(CLLocationCoordinate2D)coordinate radius:(CLLocationDistance)radius {