summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-01-28 22:08:53 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-01-28 22:23:07 -0800
commit6b3b3f3ff640e880c01aa5ac8a80eda4a309914b (patch)
tree03a1a7b625a2673bd6718179a0bd1a80ce3e625a
parent8cdd02bc8fac9f6bd63b8b943119ebdb6f480ac9 (diff)
downloadqtlocation-mapboxgl-6b3b3f3ff640e880c01aa5ac8a80eda4a309914b.tar.gz
[ios] Debug mask
Ported MGLMapDebugMaskOptions from the OS X SDK. Deprecated debugActive and -cycleDebugOptions.
-rw-r--r--include/mbgl/ios/MGLMapView.h34
-rw-r--r--ios/app/MBXViewController.mm60
-rw-r--r--ios/benchmark/MBXBenchViewController.mm1
-rw-r--r--platform/ios/src/MGLMapView.mm57
4 files changed, 117 insertions, 35 deletions
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index bd4b048d64..46383ed137 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -29,6 +29,20 @@ typedef NS_ENUM(NSUInteger, MGLAnnotationVerticalAlignment) {
MGLAnnotationVerticalAlignmentBottom,
};
+/** Options for enabling debugging features in an MGLMapView instance. */
+typedef NS_OPTIONS(NSUInteger, MGLMapDebugMaskOptions) {
+ /** Edges of tile boundaries are shown as thick, red lines to help diagnose
+ tile clipping issues. */
+ MGLMapDebugTileBoundariesMask = 1 << 1,
+ /** Each tile shows its tile coordinate (x/y/z) in the upper-left corner. */
+ MGLMapDebugTileInfoMask = 1 << 2,
+ /** Each tile shows a timestamp indicating when it was loaded. */
+ MGLMapDebugTimestampsMask = 1 << 3,
+ /** Edges of glyphs and symbols are shown as faint, green lines to help
+ diagnose collision and label placement issues. */
+ MGLMapDebugCollisionBoxesMask = 1 << 4,
+};
+
/**
An interactive, customizable map view with an interface similar to the one
provided by Apple's MapKit.
@@ -930,23 +944,19 @@ IB_DESIGNABLE
*/
- (void)removeOverlays:(NS_ARRAY_OF(id <MGLOverlay>) *)overlays;
-#pragma mark Debugging
+#pragma mark Debugging the Map
/**
- A Boolean value that determines whether map debugging information is shown.
-
- The default value of this property is `NO`.
- */
-@property (nonatomic, getter=isDebugActive) BOOL debugActive;
-
-/**
- Cycle through the options that determine which debugging aids are shown on the
- map.
+ The options that determine which debugging aids are shown on the map.
These options are all disabled by default and should remain disabled in
- released software.
+ released software for performance and aesthetic reasons.
*/
-- (void)cycleDebugOptions;
+@property (nonatomic) MGLMapDebugMaskOptions debugMask;
+
+@property (nonatomic, getter=isDebugActive) BOOL debugActive __attribute__((deprecated("Use -debugMask and -setDebugMask:.")));
+
+- (void)cycleDebugOptions __attribute__((deprecated("Use -setDebugMask:.")));
/**
Empties the in-memory tile cache.
diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index fddab78559..8269b09f32 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -104,7 +104,7 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
[defaults setObject:archivedCamera forKey:@"MBXCamera"];
[defaults setInteger:self.mapView.userTrackingMode forKey:@"MBXUserTrackingMode"];
[defaults setBool:self.mapView.showsUserLocation forKey:@"MBXShowsUserLocation"];
- [defaults setBool:self.mapView.debugActive forKey:@"MBXDebug"];
+ [defaults setInteger:self.mapView.debugMask forKey:@"MBXDebugMask"];
[defaults synchronize];
}
}
@@ -127,7 +127,11 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
self.mapView.userTrackingMode = (MGLUserTrackingMode)uncheckedTrackingMode;
}
self.mapView.showsUserLocation = [defaults boolForKey:@"MBXShowsUserLocation"];
- self.mapView.debugActive = [defaults boolForKey:@"MBXDebug"];
+ NSInteger uncheckedDebugMask = [defaults integerForKey:@"MBXDebugMask"];
+ if (uncheckedDebugMask >= 0)
+ {
+ self.mapView.debugMask = (MGLMapDebugMaskOptions)uncheckedDebugMask;
+ }
}
}
@@ -140,12 +144,24 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
- (void)showSettings
{
+ MGLMapDebugMaskOptions debugMask = self.mapView.debugMask;
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Map Settings"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Reset Position",
- @"Cycle Debug Options",
+ ((debugMask & MGLMapDebugTileBoundariesMask)
+ ? @"Hide Tile Boundaries"
+ : @"Show Tile Boundaries"),
+ ((debugMask & MGLMapDebugTileInfoMask)
+ ? @"Hide Tile Info"
+ : @"Show Tile Info"),
+ ((debugMask & MGLMapDebugTimestampsMask)
+ ? @"Hide Tile Timestamps"
+ : @"Show Tile Timestamps"),
+ ((debugMask & MGLMapDebugCollisionBoxesMask)
+ ? @"Hide Collision Boxes"
+ : @"Show Collision Boxes"),
@"Empty Memory",
@"Add 100 Points",
@"Add 1,000 Points",
@@ -154,7 +170,9 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
@"Start World Tour",
@"Add Custom Callout Point",
@"Remove Annotations",
- @"Toggle Custom Style Layer",
+ (_isShowingCustomStyleLayer
+ ? @"Hide Custom Style Layer"
+ : @"Show Custom Style Layer"),
@"Print Telemetry Logfile",
@"Delete Telemetry Logfile",
nil];
@@ -170,26 +188,38 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1)
{
- [self.mapView cycleDebugOptions];
+ self.mapView.debugMask ^= MGLMapDebugTileBoundariesMask;
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 2)
{
- [self.mapView emptyMemoryCache];
+ self.mapView.debugMask ^= MGLMapDebugTileInfoMask;
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 3)
{
- [self parseFeaturesAddingCount:100];
+ self.mapView.debugMask ^= MGLMapDebugTimestampsMask;
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 4)
{
- [self parseFeaturesAddingCount:1000];
+ self.mapView.debugMask ^= MGLMapDebugCollisionBoxesMask;
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 5)
{
- [self parseFeaturesAddingCount:10000];
+ [self.mapView emptyMemoryCache];
}
else if (buttonIndex == actionSheet.firstOtherButtonIndex + 6)
{
+ [self parseFeaturesAddingCount:100];
+ }
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 7)
+ {
+ [self parseFeaturesAddingCount:1000];
+ }
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 8)
+ {
+ [self parseFeaturesAddingCount:10000];
+ }
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9)
+ {
// PNW triangle
//
CLLocationCoordinate2D triangleCoordinates[3] =
@@ -255,19 +285,19 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
free(polygonCoordinates);
}
}
- else if (buttonIndex == actionSheet.firstOtherButtonIndex + 7)
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10)
{
[self startWorldTour:actionSheet];
}
- else if (buttonIndex == actionSheet.firstOtherButtonIndex + 8)
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 11)
{
[self presentAnnotationWithCustomCallout];
}
- else if (buttonIndex == actionSheet.firstOtherButtonIndex + 9)
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 12)
{
[self.mapView removeAnnotations:self.mapView.annotations];
}
- else if (buttonIndex == actionSheet.firstOtherButtonIndex + 10)
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 13)
{
if (_isShowingCustomStyleLayer)
{
@@ -278,12 +308,12 @@ static const CLLocationCoordinate2D WorldTourDestinations[] = {
[self insertCustomStyleLayer];
}
}
- else if (buttonIndex == actionSheet.firstOtherButtonIndex + 11)
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 14)
{
NSString *fileContents = [NSString stringWithContentsOfFile:[self telemetryDebugLogfilePath] encoding:NSUTF8StringEncoding error:nil];
NSLog(@"%@", fileContents);
}
- else if (buttonIndex == actionSheet.firstOtherButtonIndex + 12)
+ else if (buttonIndex == actionSheet.firstOtherButtonIndex + 15)
{
NSString *filePath = [self telemetryDebugLogfilePath];
if ([[NSFileManager defaultManager] isDeletableFileAtPath:filePath]) {
diff --git a/ios/benchmark/MBXBenchViewController.mm b/ios/benchmark/MBXBenchViewController.mm
index 5baaa2da3f..44ca48f436 100644
--- a/ios/benchmark/MBXBenchViewController.mm
+++ b/ios/benchmark/MBXBenchViewController.mm
@@ -52,7 +52,6 @@
self.mapView.scrollEnabled = NO;
self.mapView.rotateEnabled = NO;
self.mapView.userInteractionEnabled = YES;
- [self.mapView setDebugActive:NO];
[self startBenchmarkIteration];
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 2851efecd3..c5abf5a600 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -219,7 +219,6 @@ public:
#pragma mark - Setup & Teardown -
-@dynamic debugActive;
mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
{
return std::chrono::duration_cast<mbgl::Duration>(std::chrono::duration<NSTimeInterval>(duration));
@@ -967,7 +966,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
self.glSnapshotView.image = self.glView.snapshot;
self.glSnapshotView.hidden = NO;
- if (_mbglMap->getDebug() != mbgl::MapDebugOptions::NoDebug && [self.glSnapshotView.subviews count] == 0)
+ if (self.debugMask && [self.glSnapshotView.subviews count] == 0)
{
UIView *snapshotTint = [[UIView alloc] initWithFrame:self.glSnapshotView.bounds];
snapshotTint.autoresizingMask = self.glSnapshotView.autoresizingMask;
@@ -1641,17 +1640,61 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
return [NSSet setWithObject:@"allowsTilting"];
}
+- (MGLMapDebugMaskOptions)debugMask
+{
+ mbgl::MapDebugOptions options = _mbglMap->getDebug();
+ MGLMapDebugMaskOptions mask = 0;
+ if (options & mbgl::MapDebugOptions::TileBorders)
+ {
+ mask |= MGLMapDebugTileBoundariesMask;
+ }
+ if (options & mbgl::MapDebugOptions::ParseStatus)
+ {
+ mask |= MGLMapDebugTileInfoMask;
+ }
+ if (options & mbgl::MapDebugOptions::Timestamps)
+ {
+ mask |= MGLMapDebugTimestampsMask;
+ }
+ if (options & mbgl::MapDebugOptions::Collision)
+ {
+ mask |= MGLMapDebugCollisionBoxesMask;
+ }
+ return mask;
+}
+
+- (void)setDebugMask:(MGLMapDebugMaskOptions)debugMask
+{
+ mbgl::MapDebugOptions options = mbgl::MapDebugOptions::NoDebug;
+ if (debugMask & MGLMapDebugTileBoundariesMask)
+ {
+ options |= mbgl::MapDebugOptions::TileBorders;
+ }
+ if (debugMask & MGLMapDebugTileInfoMask)
+ {
+ options |= mbgl::MapDebugOptions::ParseStatus;
+ }
+ if (debugMask & MGLMapDebugTimestampsMask)
+ {
+ options |= mbgl::MapDebugOptions::Timestamps;
+ }
+ if (debugMask & MGLMapDebugCollisionBoxesMask)
+ {
+ options |= mbgl::MapDebugOptions::Collision;
+ }
+ _mbglMap->setDebug(options);
+}
+
- (void)setDebugActive:(BOOL)debugActive
{
- _mbglMap->setDebug(debugActive ? mbgl::MapDebugOptions::TileBorders
- | mbgl::MapDebugOptions::ParseStatus
- | mbgl::MapDebugOptions::Collision
- : mbgl::MapDebugOptions::NoDebug);
+ self.debugMask = debugActive ? (MGLMapDebugTileBoundariesMask |
+ MGLMapDebugTileInfoMask |
+ MGLMapDebugCollisionBoxesMask) : 0;
}
- (BOOL)isDebugActive
{
- return (_mbglMap->getDebug() != mbgl::MapDebugOptions::NoDebug);
+ return self.debugMask;
}
- (void)resetNorth