diff options
Diffstat (limited to 'platform')
48 files changed, 721 insertions, 71 deletions
diff --git a/platform/darwin/filesource-files.txt b/platform/darwin/filesource-files.txt index dc47142c40..095bf4c6b0 100644 --- a/platform/darwin/filesource-files.txt +++ b/platform/darwin/filesource-files.txt @@ -1,5 +1,6 @@ # File source platform/darwin/src/http_file_source.mm +platform/darwin/src/MGLLoggingConfiguration.m # Database platform/default/sqlite3.cpp diff --git a/platform/darwin/src/MGLAttributionInfo.mm b/platform/darwin/src/MGLAttributionInfo.mm index de18fe6f74..2d65a2e46e 100644 --- a/platform/darwin/src/MGLAttributionInfo.mm +++ b/platform/darwin/src/MGLAttributionInfo.mm @@ -11,6 +11,7 @@ #import "NSArray+MGLAdditions.h" #import "NSBundle+MGLAdditions.h" #import "NSString+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #include <string> @@ -91,7 +92,7 @@ options:0 usingBlock: ^(id _Nullable value, NSRange range, BOOL * _Nonnull stop) { - NSCAssert(!value || [value isKindOfClass:[NSURL class]], @"If present, URL attribute must be an NSURL."); + MGLCAssert(!value || [value isKindOfClass:[NSURL class]], @"If present, URL attribute must be an NSURL."); // Detect feedback links by the bogus style rule applied above. NSNumber *strokeWidth = [attributedString attribute:NSStrokeWidthAttributeName diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm index 890c485677..ceaf2ce475 100644 --- a/platform/darwin/src/MGLBackgroundStyleLayer.mm +++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLBackgroundStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/background_layer.hpp> @@ -21,6 +22,7 @@ - (instancetype)initWithIdentifier:(NSString *)identifier { + MGLLogDebug(@"Initializing %@ with identifier: %@", NSStringFromClass([self class]), identifier); auto layer = std::make_unique<mbgl::style::BackgroundLayer>(identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -34,6 +36,7 @@ - (void)setBackgroundColor:(NSExpression *)backgroundColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting backgroundColor: %@", backgroundColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(backgroundColor, false); self.rawLayer->setBackgroundColor(mbglValue); @@ -51,6 +54,7 @@ - (void)setBackgroundColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting backgroundColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setBackgroundColorTransition(options); @@ -69,6 +73,7 @@ - (void)setBackgroundOpacity:(NSExpression *)backgroundOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting backgroundOpacity: %@", backgroundOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(backgroundOpacity, false); self.rawLayer->setBackgroundOpacity(mbglValue); @@ -86,6 +91,7 @@ - (void)setBackgroundOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting backgroundOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setBackgroundOpacityTransition(options); @@ -104,6 +110,7 @@ - (void)setBackgroundPattern:(NSExpression *)backgroundPattern { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting backgroundPattern: %@", backgroundPattern); auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue<mbgl::style::PropertyValue<std::string>>(backgroundPattern, false); self.rawLayer->setBackgroundPattern(mbglValue); @@ -121,6 +128,7 @@ - (void)setBackgroundPatternTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting backgroundPatternTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setBackgroundPatternTransition(options); diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm index a391d72e7f..dd3729829c 100644 --- a/platform/darwin/src/MGLCircleStyleLayer.mm +++ b/platform/darwin/src/MGLCircleStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLCircleStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/circle_layer.hpp> @@ -40,6 +41,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::CircleLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -67,6 +69,7 @@ namespace mbgl { - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -74,6 +77,7 @@ namespace mbgl { - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -89,6 +93,7 @@ namespace mbgl { - (void)setCircleBlur:(NSExpression *)circleBlur { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleBlur: %@", circleBlur); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleBlur, true); self.rawLayer->setCircleBlur(mbglValue); @@ -106,6 +111,7 @@ namespace mbgl { - (void)setCircleBlurTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleBlurTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleBlurTransition(options); @@ -124,6 +130,7 @@ namespace mbgl { - (void)setCircleColor:(NSExpression *)circleColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleColor: %@", circleColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(circleColor, true); self.rawLayer->setCircleColor(mbglValue); @@ -141,6 +148,7 @@ namespace mbgl { - (void)setCircleColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleColorTransition(options); @@ -159,6 +167,7 @@ namespace mbgl { - (void)setCircleOpacity:(NSExpression *)circleOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleOpacity: %@", circleOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleOpacity, true); self.rawLayer->setCircleOpacity(mbglValue); @@ -176,6 +185,7 @@ namespace mbgl { - (void)setCircleOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleOpacityTransition(options); @@ -194,6 +204,7 @@ namespace mbgl { - (void)setCirclePitchAlignment:(NSExpression *)circlePitchAlignment { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circlePitchAlignment: %@", circlePitchAlignment); auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLCirclePitchAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::AlignmentType>>(circlePitchAlignment, false); self.rawLayer->setCirclePitchAlignment(mbglValue); @@ -211,6 +222,7 @@ namespace mbgl { - (void)setCircleRadius:(NSExpression *)circleRadius { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleRadius: %@", circleRadius); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleRadius, true); self.rawLayer->setCircleRadius(mbglValue); @@ -228,6 +240,7 @@ namespace mbgl { - (void)setCircleRadiusTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleRadiusTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleRadiusTransition(options); @@ -246,6 +259,7 @@ namespace mbgl { - (void)setCircleScaleAlignment:(NSExpression *)circleScaleAlignment { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleScaleAlignment: %@", circleScaleAlignment); auto mbglValue = MGLStyleValueTransformer<mbgl::style::CirclePitchScaleType, NSValue *, mbgl::style::CirclePitchScaleType, MGLCircleScaleAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::CirclePitchScaleType>>(circleScaleAlignment, false); self.rawLayer->setCirclePitchScale(mbglValue); @@ -270,6 +284,7 @@ namespace mbgl { - (void)setCircleStrokeColor:(NSExpression *)circleStrokeColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleStrokeColor: %@", circleStrokeColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(circleStrokeColor, true); self.rawLayer->setCircleStrokeColor(mbglValue); @@ -287,6 +302,7 @@ namespace mbgl { - (void)setCircleStrokeColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleStrokeColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleStrokeColorTransition(options); @@ -305,6 +321,7 @@ namespace mbgl { - (void)setCircleStrokeOpacity:(NSExpression *)circleStrokeOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleStrokeOpacity: %@", circleStrokeOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleStrokeOpacity, true); self.rawLayer->setCircleStrokeOpacity(mbglValue); @@ -322,6 +339,7 @@ namespace mbgl { - (void)setCircleStrokeOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleStrokeOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleStrokeOpacityTransition(options); @@ -340,6 +358,7 @@ namespace mbgl { - (void)setCircleStrokeWidth:(NSExpression *)circleStrokeWidth { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleStrokeWidth: %@", circleStrokeWidth); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(circleStrokeWidth, true); self.rawLayer->setCircleStrokeWidth(mbglValue); @@ -357,6 +376,7 @@ namespace mbgl { - (void)setCircleStrokeWidthTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleStrokeWidthTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleStrokeWidthTransition(options); @@ -375,6 +395,7 @@ namespace mbgl { - (void)setCircleTranslation:(NSExpression *)circleTranslation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleTranslation: %@", circleTranslation); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(circleTranslation, false); self.rawLayer->setCircleTranslate(mbglValue); @@ -392,6 +413,7 @@ namespace mbgl { - (void)setCircleTranslationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleTranslationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setCircleTranslateTransition(options); @@ -417,6 +439,7 @@ namespace mbgl { - (void)setCircleTranslationAnchor:(NSExpression *)circleTranslationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting circleTranslationAnchor: %@", circleTranslationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLCircleTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(circleTranslationAnchor, false); self.rawLayer->setCircleTranslateAnchor(mbglValue); diff --git a/platform/darwin/src/MGLClockDirectionFormatter.m b/platform/darwin/src/MGLClockDirectionFormatter.m index 62a0ea995d..922a1db9a2 100644 --- a/platform/darwin/src/MGLClockDirectionFormatter.m +++ b/platform/darwin/src/MGLClockDirectionFormatter.m @@ -1,6 +1,7 @@ #import "MGLClockDirectionFormatter.h" #import "NSBundle+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #define wrap(value, min, max) \ (fmod((fmod((value - min), (max - min)) + (max - min)), (max - min)) + min) @@ -52,7 +53,7 @@ } - (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error { - NSAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented"); + MGLAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented"); return NO; } diff --git a/platform/darwin/src/MGLCompassDirectionFormatter.m b/platform/darwin/src/MGLCompassDirectionFormatter.m index 1ac6a82162..99de32b777 100644 --- a/platform/darwin/src/MGLCompassDirectionFormatter.m +++ b/platform/darwin/src/MGLCompassDirectionFormatter.m @@ -1,6 +1,7 @@ #import "MGLCompassDirectionFormatter.h" #import "NSBundle+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #define wrap(value, min, max) \ (fmod((fmod((value - min), (max - min)) + (max - min)), (max - min)) + min) @@ -95,7 +96,7 @@ NSLocalizedStringWithDefaultValue(@"COMPASS_NbW_LONG", @"Foundation", nil, @"north by west", @"North by west, long"), ]; - NSAssert(shortStrings.count == longStrings.count, @"Long and short compass direction string arrays must have the same size."); + MGLAssert(shortStrings.count == longStrings.count, @"Long and short compass direction string arrays must have the same size."); }); NSInteger cardinalPoint = wrap(round(wrap(direction, 0, 360) / 360 * shortStrings.count), 0, shortStrings.count); @@ -117,7 +118,7 @@ } - (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error { - NSAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented"); + MGLAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented"); return NO; } diff --git a/platform/darwin/src/MGLCoordinateFormatter.m b/platform/darwin/src/MGLCoordinateFormatter.m index fb577d3be3..aba34e470d 100644 --- a/platform/darwin/src/MGLCoordinateFormatter.m +++ b/platform/darwin/src/MGLCoordinateFormatter.m @@ -2,6 +2,7 @@ #import "NSBundle+MGLAdditions.h" #import "NSValue+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" @implementation MGLCoordinateFormatter @@ -119,7 +120,7 @@ } - (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error { - NSAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented"); + MGLAssert(NO, @"-getObjectValue:forString:errorDescription: has not been implemented"); return NO; } diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index be327a23ab..2298960025 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -13,6 +13,7 @@ #import "NSDictionary+MGLAdditions.h" #import "NSArray+MGLAdditions.h" #import "NSExpression+MGLPrivateAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/util/geometry.hpp> #import <mbgl/style/conversion/geojson.hpp> @@ -31,6 +32,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -65,6 +67,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -100,6 +103,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -136,6 +140,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -172,6 +177,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -198,6 +204,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -234,6 +241,7 @@ MGL_DEFINE_FEATURE_ENCODE(); MGL_DEFINE_FEATURE_IS_EQUAL(); - (id)attributeForKey:(NSString *)key { + MGLLogDebug(@"Retrieving attributeForKey: %@", key); return self.attributes[key]; } @@ -288,7 +296,7 @@ MGL_DEFINE_FEATURE_IS_EQUAL(); featureCollection.reserve(self.shapes.count); for (MGLShape <MGLFeature> *feature in self.shapes) { auto geoJSONObject = feature.geoJSONObject; - NSAssert(geoJSONObject.is<mbgl::Feature>(), @"Feature collection must only contain features."); + MGLAssert(geoJSONObject.is<mbgl::Feature>(), @"Feature collection must only contain features."); featureCollection.push_back(geoJSONObject.get<mbgl::Feature>()); } return featureCollection; diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm index 570b83b854..09a58e37bb 100644 --- a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm +++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLFillExtrusionStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/fill_extrusion_layer.hpp> @@ -30,6 +31,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::FillExtrusionLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -57,6 +59,7 @@ namespace mbgl { - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -64,6 +67,7 @@ namespace mbgl { - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -79,6 +83,7 @@ namespace mbgl { - (void)setFillExtrusionBase:(NSExpression *)fillExtrusionBase { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionBase: %@", fillExtrusionBase); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionBase, true); self.rawLayer->setFillExtrusionBase(mbglValue); @@ -96,6 +101,7 @@ namespace mbgl { - (void)setFillExtrusionBaseTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionBaseTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillExtrusionBaseTransition(options); @@ -114,6 +120,7 @@ namespace mbgl { - (void)setFillExtrusionColor:(NSExpression *)fillExtrusionColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionColor: %@", fillExtrusionColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillExtrusionColor, true); self.rawLayer->setFillExtrusionColor(mbglValue); @@ -131,6 +138,7 @@ namespace mbgl { - (void)setFillExtrusionColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillExtrusionColorTransition(options); @@ -149,6 +157,7 @@ namespace mbgl { - (void)setFillExtrusionHeight:(NSExpression *)fillExtrusionHeight { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionHeight: %@", fillExtrusionHeight); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionHeight, true); self.rawLayer->setFillExtrusionHeight(mbglValue); @@ -166,6 +175,7 @@ namespace mbgl { - (void)setFillExtrusionHeightTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionHeightTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillExtrusionHeightTransition(options); @@ -184,6 +194,7 @@ namespace mbgl { - (void)setFillExtrusionOpacity:(NSExpression *)fillExtrusionOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionOpacity: %@", fillExtrusionOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillExtrusionOpacity, false); self.rawLayer->setFillExtrusionOpacity(mbglValue); @@ -201,6 +212,7 @@ namespace mbgl { - (void)setFillExtrusionOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillExtrusionOpacityTransition(options); @@ -219,6 +231,7 @@ namespace mbgl { - (void)setFillExtrusionPattern:(NSExpression *)fillExtrusionPattern { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionPattern: %@", fillExtrusionPattern); auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue<mbgl::style::PropertyValue<std::string>>(fillExtrusionPattern, true); self.rawLayer->setFillExtrusionPattern(mbglValue); @@ -236,6 +249,7 @@ namespace mbgl { - (void)setFillExtrusionPatternTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionPatternTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillExtrusionPatternTransition(options); @@ -254,6 +268,7 @@ namespace mbgl { - (void)setFillExtrusionTranslation:(NSExpression *)fillExtrusionTranslation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionTranslation: %@", fillExtrusionTranslation); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(fillExtrusionTranslation, false); self.rawLayer->setFillExtrusionTranslate(mbglValue); @@ -271,6 +286,7 @@ namespace mbgl { - (void)setFillExtrusionTranslationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionTranslationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillExtrusionTranslateTransition(options); @@ -296,6 +312,7 @@ namespace mbgl { - (void)setFillExtrusionTranslationAnchor:(NSExpression *)fillExtrusionTranslationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillExtrusionTranslationAnchor: %@", fillExtrusionTranslationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillExtrusionTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(fillExtrusionTranslationAnchor, false); self.rawLayer->setFillExtrusionTranslateAnchor(mbglValue); diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm index bb8c7fc1f2..1d4882edd3 100644 --- a/platform/darwin/src/MGLFillStyleLayer.mm +++ b/platform/darwin/src/MGLFillStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLFillStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/fill_layer.hpp> @@ -30,6 +31,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::FillLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -57,6 +59,7 @@ namespace mbgl { - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -64,6 +67,7 @@ namespace mbgl { - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -79,6 +83,7 @@ namespace mbgl { - (void)setFillAntialiased:(NSExpression *)fillAntialiased { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillAntialiased: %@", fillAntialiased); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(fillAntialiased, false); self.rawLayer->setFillAntialias(mbglValue); @@ -103,6 +108,7 @@ namespace mbgl { - (void)setFillColor:(NSExpression *)fillColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillColor: %@", fillColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillColor, true); self.rawLayer->setFillColor(mbglValue); @@ -120,6 +126,7 @@ namespace mbgl { - (void)setFillColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillColorTransition(options); @@ -138,6 +145,7 @@ namespace mbgl { - (void)setFillOpacity:(NSExpression *)fillOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillOpacity: %@", fillOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(fillOpacity, true); self.rawLayer->setFillOpacity(mbglValue); @@ -155,6 +163,7 @@ namespace mbgl { - (void)setFillOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillOpacityTransition(options); @@ -173,6 +182,7 @@ namespace mbgl { - (void)setFillOutlineColor:(NSExpression *)fillOutlineColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillOutlineColor: %@", fillOutlineColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(fillOutlineColor, true); self.rawLayer->setFillOutlineColor(mbglValue); @@ -190,6 +200,7 @@ namespace mbgl { - (void)setFillOutlineColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillOutlineColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillOutlineColorTransition(options); @@ -208,6 +219,7 @@ namespace mbgl { - (void)setFillPattern:(NSExpression *)fillPattern { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillPattern: %@", fillPattern); auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue<mbgl::style::PropertyValue<std::string>>(fillPattern, true); self.rawLayer->setFillPattern(mbglValue); @@ -225,6 +237,7 @@ namespace mbgl { - (void)setFillPatternTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillPatternTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillPatternTransition(options); @@ -243,6 +256,7 @@ namespace mbgl { - (void)setFillTranslation:(NSExpression *)fillTranslation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillTranslation: %@", fillTranslation); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(fillTranslation, false); self.rawLayer->setFillTranslate(mbglValue); @@ -260,6 +274,7 @@ namespace mbgl { - (void)setFillTranslationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillTranslationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setFillTranslateTransition(options); @@ -285,6 +300,7 @@ namespace mbgl { - (void)setFillTranslationAnchor:(NSExpression *)fillTranslationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting fillTranslationAnchor: %@", fillTranslationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLFillTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(fillTranslationAnchor, false); self.rawLayer->setFillTranslateAnchor(mbglValue); diff --git a/platform/darwin/src/MGLGeometry_Private.h b/platform/darwin/src/MGLGeometry_Private.h index b4afce82be..adf9036baa 100644 --- a/platform/darwin/src/MGLGeometry_Private.h +++ b/platform/darwin/src/MGLGeometry_Private.h @@ -19,6 +19,10 @@ typedef struct MGLRadianCoordinate2D { MGLLocationRadians longitude; } MGLRadianCoordinate2D; +NS_INLINE NSString *MGLStringFromCLLocationCoordinate2D(CLLocationCoordinate2D coordinate) { + return [NSString stringWithFormat:@"(lat: %f, lon: %f)", coordinate.latitude, coordinate.longitude]; +} + /** Creates a new `MGLRadianCoordinate2D` from the given latitudinal and longitudinal. */ diff --git a/platform/darwin/src/MGLHeatmapStyleLayer.mm b/platform/darwin/src/MGLHeatmapStyleLayer.mm index c74869d408..76675585f3 100644 --- a/platform/darwin/src/MGLHeatmapStyleLayer.mm +++ b/platform/darwin/src/MGLHeatmapStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLHeatmapStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/heatmap_layer.hpp> @@ -21,6 +22,7 @@ - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::HeatmapLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -48,6 +50,7 @@ - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -55,6 +58,7 @@ - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -70,6 +74,7 @@ - (void)setHeatmapColor:(NSExpression *)heatmapColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapColor: %@", heatmapColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(heatmapColor); self.rawLayer->setHeatmapColor(mbglValue); @@ -87,6 +92,7 @@ - (void)setHeatmapIntensity:(NSExpression *)heatmapIntensity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapIntensity: %@", heatmapIntensity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapIntensity, false); self.rawLayer->setHeatmapIntensity(mbglValue); @@ -104,6 +110,7 @@ - (void)setHeatmapIntensityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapIntensityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHeatmapIntensityTransition(options); @@ -122,6 +129,7 @@ - (void)setHeatmapOpacity:(NSExpression *)heatmapOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapOpacity: %@", heatmapOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapOpacity, false); self.rawLayer->setHeatmapOpacity(mbglValue); @@ -139,6 +147,7 @@ - (void)setHeatmapOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHeatmapOpacityTransition(options); @@ -157,6 +166,7 @@ - (void)setHeatmapRadius:(NSExpression *)heatmapRadius { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapRadius: %@", heatmapRadius); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapRadius, true); self.rawLayer->setHeatmapRadius(mbglValue); @@ -174,6 +184,7 @@ - (void)setHeatmapRadiusTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapRadiusTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHeatmapRadiusTransition(options); @@ -192,6 +203,7 @@ - (void)setHeatmapWeight:(NSExpression *)heatmapWeight { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting heatmapWeight: %@", heatmapWeight); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(heatmapWeight, true); self.rawLayer->setHeatmapWeight(mbglValue); diff --git a/platform/darwin/src/MGLHillshadeStyleLayer.mm b/platform/darwin/src/MGLHillshadeStyleLayer.mm index 16d043f603..dcc18ba54d 100644 --- a/platform/darwin/src/MGLHillshadeStyleLayer.mm +++ b/platform/darwin/src/MGLHillshadeStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLHillshadeStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/hillshade_layer.hpp> @@ -30,6 +31,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::HillshadeLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -50,6 +52,7 @@ namespace mbgl { - (void)setHillshadeAccentColor:(NSExpression *)hillshadeAccentColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeAccentColor: %@", hillshadeAccentColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(hillshadeAccentColor, false); self.rawLayer->setHillshadeAccentColor(mbglValue); @@ -67,6 +70,7 @@ namespace mbgl { - (void)setHillshadeAccentColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeAccentColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHillshadeAccentColorTransition(options); @@ -85,6 +89,7 @@ namespace mbgl { - (void)setHillshadeExaggeration:(NSExpression *)hillshadeExaggeration { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeExaggeration: %@", hillshadeExaggeration); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(hillshadeExaggeration, false); self.rawLayer->setHillshadeExaggeration(mbglValue); @@ -102,6 +107,7 @@ namespace mbgl { - (void)setHillshadeExaggerationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeExaggerationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHillshadeExaggerationTransition(options); @@ -120,6 +126,7 @@ namespace mbgl { - (void)setHillshadeHighlightColor:(NSExpression *)hillshadeHighlightColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeHighlightColor: %@", hillshadeHighlightColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(hillshadeHighlightColor, false); self.rawLayer->setHillshadeHighlightColor(mbglValue); @@ -137,6 +144,7 @@ namespace mbgl { - (void)setHillshadeHighlightColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeHighlightColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHillshadeHighlightColorTransition(options); @@ -155,6 +163,7 @@ namespace mbgl { - (void)setHillshadeIlluminationAnchor:(NSExpression *)hillshadeIlluminationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeIlluminationAnchor: %@", hillshadeIlluminationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::HillshadeIlluminationAnchorType, NSValue *, mbgl::style::HillshadeIlluminationAnchorType, MGLHillshadeIlluminationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::HillshadeIlluminationAnchorType>>(hillshadeIlluminationAnchor, false); self.rawLayer->setHillshadeIlluminationAnchor(mbglValue); @@ -172,6 +181,7 @@ namespace mbgl { - (void)setHillshadeIlluminationDirection:(NSExpression *)hillshadeIlluminationDirection { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeIlluminationDirection: %@", hillshadeIlluminationDirection); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(hillshadeIlluminationDirection, false); self.rawLayer->setHillshadeIlluminationDirection(mbglValue); @@ -189,6 +199,7 @@ namespace mbgl { - (void)setHillshadeShadowColor:(NSExpression *)hillshadeShadowColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeShadowColor: %@", hillshadeShadowColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(hillshadeShadowColor, false); self.rawLayer->setHillshadeShadowColor(mbglValue); @@ -206,6 +217,7 @@ namespace mbgl { - (void)setHillshadeShadowColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting hillshadeShadowColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setHillshadeShadowColorTransition(options); diff --git a/platform/darwin/src/MGLLight.mm b/platform/darwin/src/MGLLight.mm index 0234e74d5b..190391687e 100644 --- a/platform/darwin/src/MGLLight.mm +++ b/platform/darwin/src/MGLLight.mm @@ -8,6 +8,7 @@ #import "NSDate+MGLAdditions.h" #import "MGLStyleValue_Private.h" #import "NSValue+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/style/light.hpp> #import <mbgl/style/types.hpp> @@ -43,6 +44,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition - (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight { if (self = [super init]) { + MGLLogInfo(@"Initializing %@.", NSStringFromClass([self class])); auto anchor = mbglLight->getAnchor(); NSExpression *anchorExpression; if (anchor.isUndefined()) { @@ -105,4 +107,41 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition return mbglLight; } + + +- (void)setAnchor:(NSExpression *)anchor { + MGLLogDebug(@"Setting anchor: %@", anchor); + _anchor = anchor; +} + +- (void)setPosition:(NSExpression *)position { + MGLLogDebug(@"Setting position: %@", position); + _position = position; +} + +- (void)setPositionTransition:(MGLTransition)transition { + MGLLogDebug(@"Setting positionTransition: %@", MGLStringFromMGLTransition(transition)); + _positionTransition = transition; +} + +- (void)setColor:(NSExpression *)color { + MGLLogDebug(@"Setting color: %@", color); + _color = color; +} + +- (void)setColorTransition:(MGLTransition)transition { + MGLLogDebug(@"Setting colorTransition: %@", MGLStringFromMGLTransition(transition)); + _colorTransition = transition; +} + +- (void)setIntensity:(NSExpression *)intensity { + MGLLogDebug(@"Setting intensity: %@", intensity); + _intensity = intensity; +} + +- (void)setIntensityTransition:(MGLTransition)transition { + MGLLogDebug(@"Setting intensityTransition: %@", MGLStringFromMGLTransition(transition)); + _intensityTransition = transition; +} + @end diff --git a/platform/darwin/src/MGLLight.mm.ejs b/platform/darwin/src/MGLLight.mm.ejs index 24ab1d8138..df79f4c842 100644 --- a/platform/darwin/src/MGLLight.mm.ejs +++ b/platform/darwin/src/MGLLight.mm.ejs @@ -11,6 +11,7 @@ #import "NSDate+MGLAdditions.h" #import "MGLStyleValue_Private.h" #import "NSValue+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/style/light.hpp> #import <mbgl/style/types.hpp> @@ -51,6 +52,7 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition - (instancetype)initWithMBGLLight:(const mbgl::style::Light *)mbglLight { if (self = [super init]) { + MGLLogInfo(@"Initializing %@.", NSStringFromClass([self class])); <% if (properties.length) { -%> <% for (const property of properties) { -%> <% if (property.type == "enum") { -%> @@ -111,4 +113,22 @@ NS_INLINE mbgl::style::TransitionOptions MGLOptionsFromTransition(MGLTransition return mbglLight; } +<% if (properties.length) { -%> + +<% for (const property of properties) { -%> + +- (void)set<%- camelize(property.name) %>:(NSExpression *)<%- objCName(property) %> { + MGLLogDebug(@"Setting <%- objCName(property) %>: %@", <%- objCName(property) %>); + _<%- objCName(property) %> = <%- objCName(property) %>; +} +<% if (property["transition"]) { -%> + +- (void)set<%- camelize(property.name) %>Transition:(MGLTransition)transition { + MGLLogDebug(@"Setting <%- objCName(property) %>Transition: %@", MGLStringFromMGLTransition(transition)); + _<%- objCName(property) %>Transition = transition; +} +<% } -%> +<% } -%> +<% } -%> + @end diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm index 0f749f90af..1409a4608d 100644 --- a/platform/darwin/src/MGLLineStyleLayer.mm +++ b/platform/darwin/src/MGLLineStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLLineStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/line_layer.hpp> @@ -42,6 +43,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::LineLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -69,6 +71,7 @@ namespace mbgl { - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -76,6 +79,7 @@ namespace mbgl { - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -91,6 +95,7 @@ namespace mbgl { - (void)setLineCap:(NSExpression *)lineCap { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineCap: %@", lineCap); auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineCapType, NSValue *, mbgl::style::LineCapType, MGLLineCap>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::LineCapType>>(lineCap, false); self.rawLayer->setLineCap(mbglValue); @@ -108,6 +113,7 @@ namespace mbgl { - (void)setLineJoin:(NSExpression *)lineJoin { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineJoin: %@", lineJoin); auto mbglValue = MGLStyleValueTransformer<mbgl::style::LineJoinType, NSValue *, mbgl::style::LineJoinType, MGLLineJoin>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::LineJoinType>>(lineJoin, true); self.rawLayer->setLineJoin(mbglValue); @@ -125,6 +131,7 @@ namespace mbgl { - (void)setLineMiterLimit:(NSExpression *)lineMiterLimit { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineMiterLimit: %@", lineMiterLimit); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineMiterLimit, false); self.rawLayer->setLineMiterLimit(mbglValue); @@ -142,6 +149,7 @@ namespace mbgl { - (void)setLineRoundLimit:(NSExpression *)lineRoundLimit { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineRoundLimit: %@", lineRoundLimit); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineRoundLimit, false); self.rawLayer->setLineRoundLimit(mbglValue); @@ -161,6 +169,7 @@ namespace mbgl { - (void)setLineBlur:(NSExpression *)lineBlur { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineBlur: %@", lineBlur); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineBlur, true); self.rawLayer->setLineBlur(mbglValue); @@ -178,6 +187,7 @@ namespace mbgl { - (void)setLineBlurTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineBlurTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineBlurTransition(options); @@ -196,6 +206,7 @@ namespace mbgl { - (void)setLineColor:(NSExpression *)lineColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineColor: %@", lineColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(lineColor, true); self.rawLayer->setLineColor(mbglValue); @@ -213,6 +224,7 @@ namespace mbgl { - (void)setLineColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineColorTransition(options); @@ -231,6 +243,7 @@ namespace mbgl { - (void)setLineDashPattern:(NSExpression *)lineDashPattern { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineDashPattern: %@", lineDashPattern); auto mbglValue = MGLStyleValueTransformer<std::vector<float>, NSArray<NSNumber *> *, float>().toPropertyValue<mbgl::style::PropertyValue<std::vector<float>>>(lineDashPattern, false); self.rawLayer->setLineDasharray(mbglValue); @@ -248,6 +261,7 @@ namespace mbgl { - (void)setLineDashPatternTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineDashPatternTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineDasharrayTransition(options); @@ -273,6 +287,7 @@ namespace mbgl { - (void)setLineGapWidth:(NSExpression *)lineGapWidth { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineGapWidth: %@", lineGapWidth); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineGapWidth, true); self.rawLayer->setLineGapWidth(mbglValue); @@ -290,6 +305,7 @@ namespace mbgl { - (void)setLineGapWidthTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineGapWidthTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineGapWidthTransition(options); @@ -308,6 +324,7 @@ namespace mbgl { - (void)setLineGradient:(NSExpression *)lineGradient { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineGradient: %@", lineGradient); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::ColorRampPropertyValue>(lineGradient); self.rawLayer->setLineGradient(mbglValue); @@ -325,6 +342,7 @@ namespace mbgl { - (void)setLineOffset:(NSExpression *)lineOffset { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineOffset: %@", lineOffset); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineOffset, true); self.rawLayer->setLineOffset(mbglValue); @@ -342,6 +360,7 @@ namespace mbgl { - (void)setLineOffsetTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineOffsetTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineOffsetTransition(options); @@ -360,6 +379,7 @@ namespace mbgl { - (void)setLineOpacity:(NSExpression *)lineOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineOpacity: %@", lineOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineOpacity, true); self.rawLayer->setLineOpacity(mbglValue); @@ -377,6 +397,7 @@ namespace mbgl { - (void)setLineOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineOpacityTransition(options); @@ -395,6 +416,7 @@ namespace mbgl { - (void)setLinePattern:(NSExpression *)linePattern { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting linePattern: %@", linePattern); auto mbglValue = MGLStyleValueTransformer<std::string, NSString *>().toPropertyValue<mbgl::style::PropertyValue<std::string>>(linePattern, true); self.rawLayer->setLinePattern(mbglValue); @@ -412,6 +434,7 @@ namespace mbgl { - (void)setLinePatternTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting linePatternTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLinePatternTransition(options); @@ -430,6 +453,7 @@ namespace mbgl { - (void)setLineTranslation:(NSExpression *)lineTranslation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineTranslation: %@", lineTranslation); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(lineTranslation, false); self.rawLayer->setLineTranslate(mbglValue); @@ -447,6 +471,7 @@ namespace mbgl { - (void)setLineTranslationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineTranslationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineTranslateTransition(options); @@ -472,6 +497,7 @@ namespace mbgl { - (void)setLineTranslationAnchor:(NSExpression *)lineTranslationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineTranslationAnchor: %@", lineTranslationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLLineTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(lineTranslationAnchor, false); self.rawLayer->setLineTranslateAnchor(mbglValue); @@ -496,6 +522,7 @@ namespace mbgl { - (void)setLineWidth:(NSExpression *)lineWidth { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineWidth: %@", lineWidth); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(lineWidth, true); self.rawLayer->setLineWidth(mbglValue); @@ -513,6 +540,7 @@ namespace mbgl { - (void)setLineWidthTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting lineWidthTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setLineWidthTransition(options); diff --git a/platform/darwin/src/MGLLoggingConfiguration.h b/platform/darwin/src/MGLLoggingConfiguration.h index b467f80d31..6782dc60a7 100644 --- a/platform/darwin/src/MGLLoggingConfiguration.h +++ b/platform/darwin/src/MGLLoggingConfiguration.h @@ -2,6 +2,13 @@ #import "MGLFoundation.h" +#ifndef MGL_LOGGING_DISABLED + #ifndef MGL_LOGGING_ENABLE_DEBUG + #ifdef DEBUG + #define MGL_LOGGING_ENABLE_DEBUG 1 + #endif + #endif + NS_ASSUME_NONNULL_BEGIN /** @@ -17,11 +24,13 @@ typedef NS_ENUM(NSInteger, MGLLoggingLevel) { but is not essential. */ MGLLoggingLevelInfo, +#if MGL_LOGGING_ENABLE_DEBUG /** Debug-level messages contain information that may be helpful for troubleshooting specific problems. */ MGLLoggingLevelDebug, +#endif /** Error-level messages contain information that is intended to aid in process-level errors. @@ -82,3 +91,4 @@ MGL_EXPORT @end NS_ASSUME_NONNULL_END +#endif diff --git a/platform/darwin/src/MGLLoggingConfiguration.m b/platform/darwin/src/MGLLoggingConfiguration.m index 93f2698287..fb760b7392 100644 --- a/platform/darwin/src/MGLLoggingConfiguration.m +++ b/platform/darwin/src/MGLLoggingConfiguration.m @@ -1,5 +1,6 @@ #import "MGLLoggingConfiguration_Private.h" +#ifndef MGL_LOGGING_DISABLED #if __has_builtin(__builtin_os_log_format) #import <os/log.h> #endif @@ -42,21 +43,74 @@ if (@available(iOS 10.0, macOS 10.12.0, *)) { static dispatch_once_t once; - static os_log_t mapbox_log; + static os_log_t info_log; +#if MGL_LOGGING_ENABLE_DEBUG + static os_log_t debug_log; +#endif + static os_log_t error_log; + static os_log_t fault_log; static os_log_type_t log_types[] = { OS_LOG_TYPE_DEFAULT, OS_LOG_TYPE_INFO, +#if MGL_LOGGING_ENABLE_DEBUG OS_LOG_TYPE_DEBUG, +#endif OS_LOG_TYPE_ERROR, OS_LOG_TYPE_FAULT }; dispatch_once(&once, ^ { - mapbox_log = os_log_create("com.mapbox.maps-ios-sdk", "SDK"); + info_log = os_log_create("com.mapbox.maps", "INFO"); +#if MGL_LOGGING_ENABLE_DEBUG + debug_log = os_log_create("com.mapbox.maps", "DEBUG"); +#endif + error_log = os_log_create("com.mapbox.maps", "ERROR"); + fault_log = os_log_create("com.mapbox.maps", "FAULT"); }); - NSUInteger logTypesCount = sizeof(log_types) / sizeof(os_log_type_t); - NSAssert(level <= logTypesCount, @"There is an attempt to log a non suported logging level."); + + os_log_t mapbox_log; + switch (level) { + case MGLLoggingLevelInfo: + mapbox_log = info_log; + break; +#if MGL_LOGGING_ENABLE_DEBUG + case MGLLoggingLevelDebug: + mapbox_log = debug_log; + break; +#endif + case MGLLoggingLevelError: + mapbox_log = error_log; + break; + case MGLLoggingLevelFault: + mapbox_log = fault_log; + break; + case MGLLoggingLevelNone: + default: + break; + } + os_log_type_t logType = log_types[level]; - os_log_with_type(mapbox_log, logType, "%@ - %d: %@", fileName, line, message); + os_log_with_type(mapbox_log, logType, "%@ - %lu: %@", fileName, (unsigned long)line, message); } else { - NSLog(@"[SDK] %@ - %lu: %@", fileName, line, message); + NSString *category; + switch (level) { + case MGLLoggingLevelInfo: + category = @"INFO"; + break; +#if MGL_LOGGING_ENABLE_DEBUG + case MGLLoggingLevelDebug: + category = @"DEBUG"; + break; +#endif + case MGLLoggingLevelError: + category = @"ERROR"; + break; + case MGLLoggingLevelFault: + category = @"FAULT"; + break; + case MGLLoggingLevelNone: + default: + break; + } + + NSLog(@"[%@] %@ - %lu: %@", category, fileName, (unsigned long)line, message); } }; @@ -64,3 +118,4 @@ } @end +#endif diff --git a/platform/darwin/src/MGLLoggingConfiguration_Private.h b/platform/darwin/src/MGLLoggingConfiguration_Private.h index ff7e85eed8..34e999ca72 100644 --- a/platform/darwin/src/MGLLoggingConfiguration_Private.h +++ b/platform/darwin/src/MGLLoggingConfiguration_Private.h @@ -1,9 +1,48 @@ #import "MGLLoggingConfiguration.h" +NS_INLINE NSString *MGLStringFromBOOL(BOOL value) { + return value ? @"YES" : @"NO"; +} + +#ifdef MGL_LOGGING_DISABLED + +#define MGLLogInfo(...) +#define MGLLogDebug(...) +#define MGLLogError(...) +#define MGLLogFault(...) + +#else + +#if MGL_LOGGING_ENABLE_DEBUG + #define MGLLogDebug(message, ...) MGLLogWithType(MGLLoggingLevelDebug, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#else + #define MGLLogDebug(...) +#endif + #define MGLLogInfo(message, ...) MGLLogWithType(MGLLoggingLevelInfo, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) -#define MGLLogDebug(message, ...) MGLLogWithType(MGLLoggingLevelDebug, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) #define MGLLogError(message, ...) MGLLogWithType(MGLLoggingLevelError, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) #define MGLLogFault(message, ...) MGLLogWithType(MGLLoggingLevelFault, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) + +#endif + +#define MGLAssert(expression, message, ...) \ + __extension__({ \ + if (__builtin_expect(!(expression), 0)) { \ + MGLLogFault(message, ##__VA_ARGS__); \ + } \ + NSAssert(expression, message, ##__VA_ARGS__); \ + }) +#define MGLCAssert(expression, message, ...) \ + __extension__({ \ + if (__builtin_expect(!(expression), 0)) { \ + MGLLogFault(message, ##__VA_ARGS__); \ + } \ + NSCAssert(expression, message, ##__VA_ARGS__); \ + }) + + +#ifndef MGL_LOGGING_DISABLED + #define MGLLogWithType(type, function, line, message, ...) \ { \ if ([MGLLoggingConfiguration sharedConfiguration].loggingLevel != MGLLoggingLevelNone && type <= [MGLLoggingConfiguration sharedConfiguration].loggingLevel) \ @@ -17,3 +56,4 @@ - (void)logCallingFunction:(const char *)callingFunction functionLine:(NSUInteger)functionLine messageType:(MGLLoggingLevel)type format:(id)messageFormat, ...; @end +#endif diff --git a/platform/darwin/src/MGLMapCamera.mm b/platform/darwin/src/MGLMapCamera.mm index 62f7931641..0f5dd558a8 100644 --- a/platform/darwin/src/MGLMapCamera.mm +++ b/platform/darwin/src/MGLMapCamera.mm @@ -1,5 +1,6 @@ #import "MGLMapCamera.h" #import "MGLGeometry_Private.h" +#import "MGLLoggingConfiguration_Private.h" #import <CoreLocation/CoreLocation.h> @@ -91,6 +92,7 @@ BOOL MGLEqualFloatWithAccuracy(CGFloat left, CGFloat right, CGFloat accuracy) pitch:(CGFloat)pitch heading:(CLLocationDirection)heading { + MGLLogDebug(@"Initializing withCenterCoordinate: %@ altitude: %.0fm pitch: %f° heading: %f°", MGLStringFromCLLocationCoordinate2D(centerCoordinate), altitude, pitch, heading); if (self = [super init]) { _centerCoordinate = centerCoordinate; @@ -103,6 +105,7 @@ BOOL MGLEqualFloatWithAccuracy(CGFloat left, CGFloat right, CGFloat accuracy) - (nullable instancetype)initWithCoder:(NSCoder *)coder { + MGLLogInfo(@"Initialiazing with coder."); if (self = [super init]) { _centerCoordinate = CLLocationCoordinate2DMake([coder decodeDoubleForKey:@"centerLatitude"], @@ -141,6 +144,7 @@ BOOL MGLEqualFloatWithAccuracy(CGFloat left, CGFloat right, CGFloat accuracy) } - (void)setViewingDistance:(CLLocationDistance)distance { + MGLLogDebug(@"Setting viewingDistance: %f", distance); CLLocationDirection eyeAngle = 90 - self.pitch; self.altitude = distance * sin(MGLRadiansFromDegrees(eyeAngle)); } diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm index 590c387145..3c5e36f8f2 100644 --- a/platform/darwin/src/MGLMapSnapshotter.mm +++ b/platform/darwin/src/MGLMapSnapshotter.mm @@ -15,6 +15,7 @@ #import "NSBundle+MGLAdditions.h" #import "MGLStyle.h" #import "MGLAttributionInfo_Private.h" +#import "MGLLoggingConfiguration_Private.h" #if TARGET_OS_IPHONE #import "UIImage+MGLAdditions.h" @@ -31,6 +32,12 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (instancetype _Nonnull)initWithStyleURL:(nullable NSURL *)styleURL camera:(MGLMapCamera *)camera size:(CGSize) size { +#if TARGET_OS_IPHONE + NSString *sizeString = NSStringFromCGSize(size); +#else + NSString *sizeString = NSStringFromSize(size); +#endif + MGLLogDebug(@"Initializing withStyleURL: %@ camera: %@ size: %@", styleURL, camera, sizeString); self = [super init]; if (self) { if ( !styleURL) @@ -123,7 +130,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (void)dealloc { if (_completion) { - NSAssert(_snapshotCallback, @"Snapshot in progress - there should be a valid callback"); + MGLAssert(_snapshotCallback, @"Snapshot in progress - there should be a valid callback"); [MGLMapSnapshotter completeWithErrorCode:MGLErrorCodeSnapshotFailed description:@"MGLMapSnapshotter deallocated prior to snapshot completion." @@ -134,6 +141,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (instancetype)initWithOptions:(MGLMapSnapshotOptions *)options { + MGLLogDebug(@"Initializing withOptions: %@", options); self = [super init]; if (self) { [self setOptions:options]; @@ -143,6 +151,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (void)startWithCompletionHandler:(MGLMapSnapshotCompletionHandler)completion { + MGLLogDebug(@"Starting withCompletionHandler: %@", completion); [self startWithQueue:dispatch_get_main_queue() completionHandler:completion]; } @@ -173,7 +182,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; __typeof__(self) strongSelf = weakSelf; // If self had died, _snapshotCallback would have been destroyed and this block would not be executed - NSCAssert(strongSelf, @"Snapshot callback executed after being destroyed."); + MGLCAssert(strongSelf, @"Snapshot callback executed after being destroyed."); if (!strongSelf.completion) return; @@ -500,6 +509,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (void)cancel { + MGLLogInfo(@"Cancelling snapshotter."); self.cancelled = YES; if (_snapshotCallback) { @@ -529,6 +539,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (void)setOptions:(MGLMapSnapshotOptions *)options { + MGLLogDebug(@"Setting options: %@", options); _options = options; mbgl::DefaultFileSource *mbglFileSource = [MGLOfflineStorage sharedOfflineStorage].mbglFileSource; _mbglThreadPool = mbgl::sharedThreadPool(); diff --git a/platform/darwin/src/MGLMultiPoint.mm b/platform/darwin/src/MGLMultiPoint.mm index d4518e3d8f..19aacaea43 100644 --- a/platform/darwin/src/MGLMultiPoint.mm +++ b/platform/darwin/src/MGLMultiPoint.mm @@ -3,6 +3,7 @@ #import "MGLShape_Private.h" #import "NSCoder+MGLAdditions.h" #import "MGLTypes.h" +#import "MGLLoggingConfiguration_Private.h" @implementation MGLMultiPoint { @@ -12,6 +13,7 @@ - (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count { + MGLLogDebug(@"Initializing with %lu coordinates.", (unsigned long) count); self = [super init]; if (self) @@ -28,6 +30,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder."); if (self = [super initWithCoder:decoder]) { _coordinates = [decoder mgl_decodeLocationCoordinates2DForKey:@"coordinates"]; } @@ -61,7 +64,7 @@ - (CLLocationCoordinate2D)coordinate { - NSAssert([self pointCount] > 0, @"A multipoint must have coordinates"); + MGLAssert([self pointCount] > 0, @"A multipoint must have coordinates"); return _coordinates.at(0); } @@ -93,6 +96,7 @@ } - (void)setCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count { + MGLLogDebug(@"Setting: %lu coordinates.", (unsigned long)count); if (!count) { [NSException raise:NSInvalidArgumentException format:@"A multipoint must have at least one vertex."]; @@ -105,6 +109,7 @@ } - (void)insertCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count atIndex:(NSUInteger)index { + MGLLogDebug(@"Inserting %lu coordinates at index %lu.", (unsigned long)count, (unsigned long)index); if (!count) { return; } @@ -123,15 +128,18 @@ - (void)appendCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count { + MGLLogDebug(@"Appending %lu coordinates.", (unsigned long)count); [self insertCoordinates:coords count:count atIndex:_coordinates.size()]; } - (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(const CLLocationCoordinate2D *)coords { + MGLLogDebug(@"Replacing coordinates in range: %@", NSStringFromRange(range)); [self replaceCoordinatesInRange:range withCoordinates:coords count:range.length]; } - (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count { + MGLLogDebug(@"Replacing %lu coordinates in range %@.", (unsigned long)count, NSStringFromRange(range)); if (!count && !range.length) { return; } @@ -154,6 +162,7 @@ } - (void)removeCoordinatesInRange:(NSRange)range { + MGLLogDebug(@"Removing coordinatesInRange: %@", NSStringFromRange(range)); CLLocationCoordinate2D coords; [self replaceCoordinatesInRange:range withCoordinates:&coords count:0]; } @@ -181,7 +190,7 @@ - (mbgl::Annotation)annotationObjectWithDelegate:(__unused id <MGLMultiPointDelegate>)delegate { - NSAssert(NO, @"Cannot add an annotation from an instance of %@", NSStringFromClass([self class])); + MGLAssert(NO, @"Cannot add an annotation from an instance of %@", NSStringFromClass([self class])); return mbgl::SymbolAnnotation(mbgl::Point<double>()); } diff --git a/platform/darwin/src/MGLOfflinePack.mm b/platform/darwin/src/MGLOfflinePack.mm index bafb976585..a8f807374c 100644 --- a/platform/darwin/src/MGLOfflinePack.mm +++ b/platform/darwin/src/MGLOfflinePack.mm @@ -6,6 +6,7 @@ #import "MGLTilePyramidOfflineRegion_Private.h" #import "MGLShapeOfflineRegion.h" #import "MGLShapeOfflineRegion_Private.h" +#import "MGLLoggingConfiguration_Private.h" #import "NSValue+MGLAdditions.h" @@ -60,6 +61,7 @@ private: } - (instancetype)init { + MGLLogInfo(@"Calling this initializer is not allowed."); if (self = [super init]) { _state = MGLOfflinePackStateInvalid; NSLog(@"%s called; did you mean to call +[MGLOfflineStorage addPackForRegion:withContext:completionHandler:] instead?", __PRETTY_FUNCTION__); @@ -79,15 +81,15 @@ private: } - (void)dealloc { - NSAssert(_state == MGLOfflinePackStateInvalid, @"MGLOfflinePack was not invalided prior to deallocation."); + MGLAssert(_state == MGLOfflinePackStateInvalid, @"MGLOfflinePack was not invalided prior to deallocation."); } - (id <MGLOfflineRegion>)region { MGLAssertOfflinePackIsValid(); const mbgl::OfflineRegionDefinition ®ionDefinition = _mbglOfflineRegion->getDefinition(); - NSAssert([MGLTilePyramidOfflineRegion conformsToProtocol:@protocol(MGLOfflineRegion_Private)], @"MGLTilePyramidOfflineRegion should conform to MGLOfflineRegion_Private."); - NSAssert([MGLShapeOfflineRegion conformsToProtocol:@protocol(MGLOfflineRegion_Private)], @"MGLShapeOfflineRegion should conform to MGLOfflineRegion_Private."); + MGLAssert([MGLTilePyramidOfflineRegion conformsToProtocol:@protocol(MGLOfflineRegion_Private)], @"MGLTilePyramidOfflineRegion should conform to MGLOfflineRegion_Private."); + MGLAssert([MGLShapeOfflineRegion conformsToProtocol:@protocol(MGLOfflineRegion_Private)], @"MGLShapeOfflineRegion should conform to MGLOfflineRegion_Private."); @@ -108,6 +110,7 @@ private: } - (void)resume { + MGLLogInfo(@"Resuming pack download."); MGLAssertOfflinePackIsValid(); self.state = MGLOfflinePackStateActive; @@ -117,6 +120,7 @@ private: } - (void)suspend { + MGLLogInfo(@"Suspending pack download."); MGLAssertOfflinePackIsValid(); if (self.state == MGLOfflinePackStateActive) { @@ -129,7 +133,8 @@ private: } - (void)invalidate { - NSAssert(_state != MGLOfflinePackStateInvalid, @"Cannot invalidate an already invalid offline pack."); + MGLLogInfo(@"Invalidating pack."); + MGLAssert(_state != MGLOfflinePackStateInvalid, @"Cannot invalidate an already invalid offline pack."); self.state = MGLOfflinePackStateInvalid; mbgl::DefaultFileSource *mbglFileSource = [[MGLOfflineStorage sharedOfflineStorage] mbglFileSource]; @@ -138,15 +143,16 @@ private: } - (void)setState:(MGLOfflinePackState)state { + MGLLogDebug(@"Setting state: %ld", (long)state); if (!self.mbglOfflineRegion) { // A progress update has arrived after the call to // -[MGLOfflineStorage removePack:withCompletionHandler:] but before the // removal is complete and the completion handler is called. - NSAssert(_state == MGLOfflinePackStateInvalid, @"A valid MGLOfflinePack has no mbgl::OfflineRegion."); + MGLAssert(_state == MGLOfflinePackStateInvalid, @"A valid MGLOfflinePack has no mbgl::OfflineRegion."); return; } - NSAssert(_state != MGLOfflinePackStateInvalid, @"Cannot change the state of an invalid offline pack."); + MGLAssert(_state != MGLOfflinePackStateInvalid, @"Cannot change the state of an invalid offline pack."); if (!_isSuspending || state != MGLOfflinePackStateActive) { _isSuspending = NO; @@ -155,6 +161,7 @@ private: } - (void)requestProgress { + MGLLogInfo(@"Requesting pack progress."); MGLAssertOfflinePackIsValid(); mbgl::DefaultFileSource *mbglFileSource = [[MGLOfflineStorage sharedOfflineStorage] mbglFileSource]; @@ -172,7 +179,7 @@ private: } - (void)offlineRegionStatusDidChange:(mbgl::OfflineRegionStatus)status { - NSAssert(_state != MGLOfflinePackStateInvalid, @"Cannot change update progress of an invalid offline pack."); + MGLAssert(_state != MGLOfflinePackStateInvalid, @"Cannot change update progress of an invalid offline pack."); switch (status.downloadState) { case mbgl::OfflineRegionDownloadState::Inactive: @@ -207,6 +214,9 @@ private: } - (void)didReceiveError:(NSError *)error { + MGLLogError(@"Error: %@", error.localizedDescription); + MGLLogInfo(@"Notifying about pack error."); + NSDictionary *userInfo = @{ MGLOfflinePackUserInfoKeyError: error }; NSNotificationCenter *noteCenter = [NSNotificationCenter defaultCenter]; [noteCenter postNotificationName:MGLOfflinePackErrorNotification @@ -215,6 +225,7 @@ private: } - (void)didReceiveMaximumAllowedMapboxTiles:(uint64_t)limit { + MGLLogInfo(@"Notifying reached maximum allowed Mapbox tiles: %lu", (unsigned long)limit); NSDictionary *userInfo = @{ MGLOfflinePackUserInfoKeyMaximumCount: @(limit) }; NSNotificationCenter *noteCenter = [NSNotificationCenter defaultCenter]; [noteCenter postNotificationName:MGLOfflinePackMaximumMapboxTilesReachedNotification diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm index 5e50e83274..24aaeb546c 100644 --- a/platform/darwin/src/MGLOfflineStorage.mm +++ b/platform/darwin/src/MGLOfflineStorage.mm @@ -12,6 +12,7 @@ #import "NSValue+MGLAdditions.h" #import "NSDate+MGLAdditions.h" #import "NSData+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR #import "MMEConstants.h" @@ -87,6 +88,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio #endif - (void)setDelegate:(id<MGLOfflineStorageDelegate>)newValue { + MGLLogDebug(@"Setting delegate: %@", newValue); _delegate = newValue; if ([self.delegate respondsToSelector:@selector(offlineStorage:URLForResourceOfKind:withURL:)]) { _mbglResourceTransform = std::make_unique<mbgl::Actor<mbgl::ResourceTransform>>(*mbgl::Scheduler::GetCurrent(), [offlineStorage = self](auto kind_, const std::string&& url_) -> std::string { @@ -276,6 +278,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio #pragma mark Offline merge methods - (void)addContentsOfFile:(NSString *)filePath withCompletionHandler:(MGLBatchedOfflinePackAdditionCompletionHandler)completion { + MGLLogDebug(@"Adding contentsOfFile: %@ completionHandler: %@", filePath, completion); NSURL *fileURL = [NSURL fileURLWithPath:filePath]; [self addContentsOfURL:fileURL withCompletionHandler:completion]; @@ -283,7 +286,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio } - (void)addContentsOfURL:(NSURL *)fileURL withCompletionHandler:(MGLBatchedOfflinePackAdditionCompletionHandler)completion { - + MGLLogDebug(@"Adding contentsOfURL: %@ completionHandler: %@", fileURL, completion); NSFileManager *fileManager = [NSFileManager defaultManager]; if (!fileURL.isFileURL) { @@ -359,6 +362,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio #pragma mark Pack management methods - (void)addPackForRegion:(id <MGLOfflineRegion>)region withContext:(NSData *)context completionHandler:(MGLOfflinePackAdditionCompletionHandler)completion { + MGLLogDebug(@"Adding packForRegion: %@ contextLength: %lu completionHandler: %@", region, (unsigned long)context.length, completion); __weak MGLOfflineStorage *weakSelf = self; [self _addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack * _Nullable pack, NSError * _Nullable error) { pack.state = MGLOfflinePackStateInactive; @@ -409,6 +413,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio } - (void)removePack:(MGLOfflinePack *)pack withCompletionHandler:(MGLOfflinePackRemovalCompletionHandler)completion { + MGLLogDebug(@"Removing pack: %@ completionHandler: %@", pack, completion); [[self mutableArrayValueForKey:@"packs"] removeObject:pack]; [self _removePack:pack withCompletionHandler:^(NSError * _Nullable error) { if (completion) { @@ -441,6 +446,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio } - (void)reloadPacks { + MGLLogInfo(@"Reloading packs."); [self getPacksWithCompletionHandler:^(NSArray<MGLOfflinePack *> *packs, __unused NSError * _Nullable error) { for (MGLOfflinePack *pack in self.packs) { [pack invalidate]; @@ -474,6 +480,7 @@ const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegio } - (void)setMaximumAllowedMapboxTiles:(uint64_t)maximumCount { + MGLLogDebug(@"Setting maximumAllowedMapboxTiles: %lu", (unsigned long)maximumCount); _mbglFileSource->setOfflineMapboxTileCountLimit(maximumCount); } diff --git a/platform/darwin/src/MGLPointAnnotation.mm b/platform/darwin/src/MGLPointAnnotation.mm index 5fd3e25991..233bef0a0f 100644 --- a/platform/darwin/src/MGLPointAnnotation.mm +++ b/platform/darwin/src/MGLPointAnnotation.mm @@ -2,6 +2,7 @@ #import "MGLShape_Private.h" #import "NSCoder+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/util/geometry.hpp> @@ -17,6 +18,7 @@ - (instancetype)initWithCoder:(NSCoder *)coder { + MGLLogInfo(@"Initializing with coder."); if (self = [super initWithCoder:coder]) { self.coordinate = [coder decodeMGLCoordinateForKey:@"coordinate"]; } diff --git a/platform/darwin/src/MGLPointCollection.mm b/platform/darwin/src/MGLPointCollection.mm index efb9497a1f..f4f91f0162 100644 --- a/platform/darwin/src/MGLPointCollection.mm +++ b/platform/darwin/src/MGLPointCollection.mm @@ -1,6 +1,7 @@ #import "MGLPointCollection_Private.h" #import "MGLGeometry_Private.h" #import "NSArray+MGLAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/util/geojson.hpp> #import <mbgl/util/geometry.hpp> @@ -20,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count { + MGLLogDebug(@"Initializing with %lu coordinates.", (unsigned long)count); self = [super init]; if (self) { @@ -29,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN } - (nullable instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder.O"); if (self = [super initWithCoder:decoder]) { NSArray *coordinates = [decoder decodeObjectOfClass:[NSArray class] forKey:@"coordinates"]; _coordinates = [coordinates mgl_coordinates]; @@ -77,7 +80,7 @@ NS_ASSUME_NONNULL_BEGIN - (CLLocationCoordinate2D)coordinate { - NSAssert([self pointCount] > 0, @"A multipoint must have coordinates"); + MGLAssert([self pointCount] > 0, @"A multipoint must have coordinates"); return _coordinates.at(0); } diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm index b80504707b..6304408f7a 100644 --- a/platform/darwin/src/MGLPolygon.mm +++ b/platform/darwin/src/MGLPolygon.mm @@ -2,6 +2,7 @@ #import "MGLMultiPoint_Private.h" #import "MGLGeometry_Private.h" +#import "MGLLoggingConfiguration_Private.h" #import "MGLFeature.h" @@ -21,6 +22,7 @@ } - (instancetype)initWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(NSArray<MGLPolygon *> *)interiorPolygons { + MGLLogDebug(@"Initializing with %lu coordinates and %lu interiorPolygons.", (unsigned long)count, (unsigned long)interiorPolygons); if (self = [super initWithCoordinates:coords count:count]) { if (interiorPolygons.count) { _interiorPolygons = interiorPolygons; @@ -30,6 +32,7 @@ } - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializng with coder."); self = [super initWithCoder:decoder]; if (self) { _interiorPolygons = [decoder decodeObjectOfClass:[NSArray class] forKey:@"interiorPolygons"]; @@ -143,6 +146,7 @@ } - (instancetype)initWithPolygons:(NSArray<MGLPolygon *> *)polygons { + MGLLogDebug(@"Initializing with %lu polygons.", (unsigned long)polygons.count); if (self = [super init]) { _polygons = polygons; @@ -157,6 +161,7 @@ } - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder."); if (self = [super initWithCoder:decoder]) { _polygons = [decoder decodeObjectOfClass:[NSArray class] forKey:@"polygons"]; } diff --git a/platform/darwin/src/MGLPolyline.mm b/platform/darwin/src/MGLPolyline.mm index a028db8176..25c540b527 100644 --- a/platform/darwin/src/MGLPolyline.mm +++ b/platform/darwin/src/MGLPolyline.mm @@ -4,6 +4,7 @@ #import "MGLGeometry_Private.h" #import "MGLFeature.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/util/geojson.hpp> #import <mapbox/polylabel.hpp> @@ -64,7 +65,7 @@ - (CLLocationCoordinate2D)coordinate { NSUInteger count = self.pointCount; - NSAssert(count > 0, @"Polyline must have coordinates"); + MGLAssert(count > 0, @"Polyline must have coordinates"); CLLocationCoordinate2D *coordinates = self.coordinates; CLLocationDistance middle = [self length] / 2.0; @@ -138,6 +139,7 @@ } - (instancetype)initWithPolylines:(NSArray<MGLPolyline *> *)polylines { + MGLLogDebug(@"Initializing with %lu polylines.", (unsigned long)polylines.count); if (self = [super init]) { _polylines = polylines; @@ -152,6 +154,7 @@ } - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder."); if (self = [super initWithCoder:decoder]) { _polylines = [decoder decodeObjectOfClass:[NSArray class] forKey:@"polylines"]; } @@ -184,7 +187,7 @@ - (CLLocationCoordinate2D)coordinate { MGLPolyline *polyline = self.polylines.firstObject; CLLocationCoordinate2D *coordinates = polyline.coordinates; - NSAssert([polyline pointCount] > 0, @"Polyline must have coordinates"); + MGLAssert([polyline pointCount] > 0, @"Polyline must have coordinates"); CLLocationCoordinate2D firstCoordinate = coordinates[0]; return firstCoordinate; diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm index c87355b04d..7416400b2e 100644 --- a/platform/darwin/src/MGLRasterStyleLayer.mm +++ b/platform/darwin/src/MGLRasterStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLRasterStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/raster_layer.hpp> @@ -30,6 +31,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::RasterLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -50,6 +52,7 @@ namespace mbgl { - (void)setMaximumRasterBrightness:(NSExpression *)maximumRasterBrightness { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting maximumRasterBrightness: %@", maximumRasterBrightness); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(maximumRasterBrightness, false); self.rawLayer->setRasterBrightnessMax(mbglValue); @@ -67,6 +70,7 @@ namespace mbgl { - (void)setMaximumRasterBrightnessTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting maximumRasterBrightnessTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setRasterBrightnessMaxTransition(options); @@ -92,6 +96,7 @@ namespace mbgl { - (void)setMinimumRasterBrightness:(NSExpression *)minimumRasterBrightness { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting minimumRasterBrightness: %@", minimumRasterBrightness); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(minimumRasterBrightness, false); self.rawLayer->setRasterBrightnessMin(mbglValue); @@ -109,6 +114,7 @@ namespace mbgl { - (void)setMinimumRasterBrightnessTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting minimumRasterBrightnessTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setRasterBrightnessMinTransition(options); @@ -134,6 +140,7 @@ namespace mbgl { - (void)setRasterContrast:(NSExpression *)rasterContrast { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterContrast: %@", rasterContrast); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterContrast, false); self.rawLayer->setRasterContrast(mbglValue); @@ -151,6 +158,7 @@ namespace mbgl { - (void)setRasterContrastTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterContrastTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setRasterContrastTransition(options); @@ -169,6 +177,7 @@ namespace mbgl { - (void)setRasterFadeDuration:(NSExpression *)rasterFadeDuration { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterFadeDuration: %@", rasterFadeDuration); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterFadeDuration, false); self.rawLayer->setRasterFadeDuration(mbglValue); @@ -186,6 +195,7 @@ namespace mbgl { - (void)setRasterHueRotation:(NSExpression *)rasterHueRotation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterHueRotation: %@", rasterHueRotation); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterHueRotation, false); self.rawLayer->setRasterHueRotate(mbglValue); @@ -203,6 +213,7 @@ namespace mbgl { - (void)setRasterHueRotationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterHueRotationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setRasterHueRotateTransition(options); @@ -228,6 +239,7 @@ namespace mbgl { - (void)setRasterOpacity:(NSExpression *)rasterOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterOpacity: %@", rasterOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterOpacity, false); self.rawLayer->setRasterOpacity(mbglValue); @@ -245,6 +257,7 @@ namespace mbgl { - (void)setRasterOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setRasterOpacityTransition(options); @@ -263,6 +276,7 @@ namespace mbgl { - (void)setRasterResamplingMode:(NSExpression *)rasterResamplingMode { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterResamplingMode: %@", rasterResamplingMode); auto mbglValue = MGLStyleValueTransformer<mbgl::style::RasterResamplingType, NSValue *, mbgl::style::RasterResamplingType, MGLRasterResamplingMode>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::RasterResamplingType>>(rasterResamplingMode, false); self.rawLayer->setRasterResampling(mbglValue); @@ -287,6 +301,7 @@ namespace mbgl { - (void)setRasterSaturation:(NSExpression *)rasterSaturation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterSaturation: %@", rasterSaturation); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(rasterSaturation, false); self.rawLayer->setRasterSaturation(mbglValue); @@ -304,6 +319,7 @@ namespace mbgl { - (void)setRasterSaturationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting rasterSaturationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setRasterSaturationTransition(options); diff --git a/platform/darwin/src/MGLShapeCollection.mm b/platform/darwin/src/MGLShapeCollection.mm index 5db1ee335c..5a0ef03340 100644 --- a/platform/darwin/src/MGLShapeCollection.mm +++ b/platform/darwin/src/MGLShapeCollection.mm @@ -2,6 +2,7 @@ #import "MGLShape_Private.h" #import "MGLFeature.h" +#import "MGLLoggingConfiguration_Private.h" #import <mbgl/style/conversion/geojson.hpp> @@ -12,6 +13,7 @@ } - (instancetype)initWithShapes:(NSArray<MGLShape *> *)shapes { + MGLLogDebug(@"Initializing with %lu shapes.", (unsigned long)shapes.count); if (self = [super init]) { _shapes = shapes.copy; } @@ -19,6 +21,7 @@ } - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder."); if (self = [super initWithCoder:decoder]) { _shapes = [decoder decodeObjectOfClass:[NSArray class] forKey:@"shapes"]; } diff --git a/platform/darwin/src/MGLShapeOfflineRegion.mm b/platform/darwin/src/MGLShapeOfflineRegion.mm index c016c30ee4..67b9941a49 100644 --- a/platform/darwin/src/MGLShapeOfflineRegion.mm +++ b/platform/darwin/src/MGLShapeOfflineRegion.mm @@ -11,6 +11,7 @@ #import "MGLFeature_Private.h" #import "MGLShape_Private.h" #import "MGLStyle.h" +#import "MGLLoggingConfiguration_Private.h" #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR #import "MMEConstants.h" @@ -42,6 +43,7 @@ } - (instancetype)init { + MGLLogInfo(@"Calling this initializer is not allowed."); [NSException raise:@"Method unavailable" format: @"-[MGLShapeOfflineRegion init] is unavailable. " @@ -50,6 +52,7 @@ } - (instancetype)initWithStyleURL:(NSURL *)styleURL shape:(MGLShape *)shape fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel { + MGLLogDebug(@"Initializing styleURL: %@ shape: %@ fromZoomLevel: %f toZoomLevel: %f", styleURL, shape, minimumZoomLevel, maximumZoomLevel); if (self = [super init]) { if (!styleURL) { styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion]; @@ -91,6 +94,7 @@ } - (nullable instancetype)initWithCoder:(NSCoder *)coder { + MGLLogInfo(@"Initializing with coder."); NSURL *styleURL = [coder decodeObjectForKey:@"styleURL"]; MGLShape * shape = [coder decodeObjectForKey:@"shape"]; double minimumZoomLevel = [coder decodeDoubleForKey:@"minimumZoomLevel"]; diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 437da3fd4f..c023ed80f4 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -25,6 +25,7 @@ #import "MGLImageSource.h" #import "MGLAttributionInfo_Private.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/map/map.hpp> #include <mbgl/util/default_styles.hpp> @@ -128,11 +129,13 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, #pragma mark - - (instancetype)initWithRawStyle:(mbgl::style::Style *)rawStyle mapView:(MGLMapView *)mapView { + MGLLogInfo(@"Initializing %@ with mapView: %@", NSStringFromClass([self class]), mapView); if (self = [super init]) { _mapView = mapView; _rawStyle = rawStyle; _openGLLayers = [NSMutableDictionary dictionary]; _localizedLayersByIdentifier = [NSMutableDictionary dictionary]; + MGLLogDebug(@"Initializing with style name: %@ mapView: %@", self.name, mapView); } return self; } @@ -159,6 +162,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, } - (void)setSources:(NSSet<__kindof MGLSource *> *)sources { + MGLLogDebug(@"Setting: %lu sources", sources.count); for (MGLSource *source in self.sources) { [self removeSource:source]; } @@ -177,6 +181,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (MGLSource *)sourceWithIdentifier:(NSString *)identifier { + MGLLogDebug(@"Querying source with identifier: %@", identifier); auto rawSource = self.rawStyle->getSource(identifier.UTF8String); return rawSource ? [self sourceFromMBGLSource:rawSource] : nil; @@ -206,6 +211,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (void)addSource:(MGLSource *)source { + MGLLogDebug(@"Adding source: %@", source); if (!source.rawSource) { [NSException raise:NSInvalidArgumentException format: @"The source %@ cannot be added to the style. " @@ -222,6 +228,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (void)removeSource:(MGLSource *)source { + MGLLogDebug(@"Removing source: %@", source); if (!source.rawSource) { [NSException raise:NSInvalidArgumentException format: @"The source %@ cannot be removed from the style. " @@ -263,6 +270,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, } - (void)setLayers:(NSArray<__kindof MGLStyleLayer *> *)layers { + MGLLogDebug(@"Setting: %lu layers", layers.count); for (MGLStyleLayer *layer in self.layers) { [self removeLayer:layer]; } @@ -372,19 +380,21 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, case mbgl::style::LayerType::Custom: return [[MGLOpenGLStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::CustomLayer*>(rawLayer)]; default: - NSAssert(NO, @"Unrecognized layer type"); + MGLAssert(NO, @"Unrecognized layer type"); return nil;; } } - (MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier { + MGLLogDebug(@"Querying layerWithIdentifier: %@", identifier); auto mbglLayer = self.rawStyle->getLayer(identifier.UTF8String); return mbglLayer ? [self layerFromMBGLLayer:mbglLayer] : nil; } - (void)removeLayer:(MGLStyleLayer *)layer { + MGLLogDebug(@"Removing layer: %@", layer); if (!layer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @"The style layer %@ cannot be removed from the style. " @@ -398,6 +408,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (void)addLayer:(MGLStyleLayer *)layer { + MGLLogDebug(@"Adding layer: %@", layer); if (!layer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @"The style layer %@ cannot be added to the style. " @@ -419,6 +430,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (void)insertLayer:(MGLStyleLayer *)layer belowLayer:(MGLStyleLayer *)sibling { + MGLLogDebug(@"Inseting layer: %@ belowLayer: %@", layer, sibling); if (!layer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @@ -443,6 +455,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, } - (void)insertLayer:(MGLStyleLayer *)layer aboveLayer:(MGLStyleLayer *)sibling { + MGLLogDebug(@"Inseting layer: %@ aboveLayer: %@", layer, sibling); if (!layer.rawLayer) { [NSException raise:NSInvalidArgumentException format: @@ -496,6 +509,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (void)setImage:(MGLImage *)image forName:(NSString *)name { + MGLLogDebug(@"Setting image: %@ forName: %@", image, name); if (!image) { [NSException raise:NSInvalidArgumentException format:@"Cannot assign nil image to “%@”.", name]; @@ -510,6 +524,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (void)removeImageForName:(NSString *)name { + MGLLogDebug(@"Removing imageForName: %@", name); if (!name) { [NSException raise:NSInvalidArgumentException format:@"Cannot remove image with nil name."]; @@ -520,6 +535,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, - (MGLImage *)imageForName:(NSString *)name { + MGLLogDebug(@"Querying imageForName: %@", name); if (!name) { [NSException raise:NSInvalidArgumentException format:@"Cannot get image with nil name."]; diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs index 6d0c4bfdd9..b7be5fb9be 100644 --- a/platform/darwin/src/MGLStyleLayer.mm.ejs +++ b/platform/darwin/src/MGLStyleLayer.mm.ejs @@ -13,6 +13,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGL<%- camelize(type) %>StyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp> @@ -58,6 +59,7 @@ namespace mbgl { <% if (type == 'background') { -%> - (instancetype)initWithIdentifier:(NSString *)identifier { + MGLLogDebug(@"Initializing %@ with identifier: %@", NSStringFromClass([self class]), identifier); auto layer = std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -65,6 +67,7 @@ namespace mbgl { <% } else { -%> - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::<%- camelize(type) %>Layer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -95,6 +98,7 @@ namespace mbgl { - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -102,6 +106,7 @@ namespace mbgl { - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -120,6 +125,7 @@ namespace mbgl { <% for (const property of layoutProperties) { -%> - (void)set<%- camelize(property.name) %>:(NSExpression *)<%- objCName(property) %> { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting <%- objCName(property) %>: %@", <%- objCName(property) %>); <% if (property.tokens) { -%> if (<%- objCName(property) %> && <%- objCName(property) %>.expressionType == NSConstantValueExpressionType) { @@ -171,6 +177,7 @@ namespace mbgl { - (void)set<%- camelize(property.name) %>:(NSExpression *)<%- objCName(property) %> { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting <%- objCName(property) %>: %@", <%- objCName(property) %>); <% switch (property['property-type']) { case 'color-ramp': -%> @@ -199,6 +206,7 @@ namespace mbgl { - (void)set<%- camelize(property.name) %>Transition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting <%- objCName(property) %>Transition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->set<%- camelize(originalPropertyName(property)) %>Transition(options); diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm index e1bc7e7d20..cd293481fe 100644 --- a/platform/darwin/src/MGLSymbolStyleLayer.mm +++ b/platform/darwin/src/MGLSymbolStyleLayer.mm @@ -7,6 +7,7 @@ #import "MGLStyleLayer_Private.h" #import "MGLStyleValue_Private.h" #import "MGLSymbolStyleLayer.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/symbol_layer.hpp> @@ -113,6 +114,7 @@ namespace mbgl { - (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { + MGLLogDebug(@"Initializing %@ with identifier: %@ source: %@", NSStringFromClass([self class]), identifier, source); auto layer = std::make_unique<mbgl::style::SymbolLayer>(identifier.UTF8String, source.identifier.UTF8String); return self = [super initWithPendingLayer:std::move(layer)]; } @@ -140,6 +142,7 @@ namespace mbgl { - (void)setSourceLayerIdentifier:(NSString *)sourceLayerIdentifier { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting sourceLayerIdentifier: %@", sourceLayerIdentifier); self.rawLayer->setSourceLayer(sourceLayerIdentifier.UTF8String ?: ""); } @@ -147,6 +150,7 @@ namespace mbgl { - (void)setPredicate:(NSPredicate *)predicate { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting predicate: %@", predicate); self.rawLayer->setFilter(predicate ? predicate.mgl_filter : mbgl::style::Filter()); } @@ -162,6 +166,7 @@ namespace mbgl { - (void)setIconAllowsOverlap:(NSExpression *)iconAllowsOverlap { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconAllowsOverlap: %@", iconAllowsOverlap); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(iconAllowsOverlap, false); self.rawLayer->setIconAllowOverlap(mbglValue); @@ -186,6 +191,7 @@ namespace mbgl { - (void)setIconAnchor:(NSExpression *)iconAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconAnchor: %@", iconAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::SymbolAnchorType, NSValue *, mbgl::style::SymbolAnchorType, MGLIconAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::SymbolAnchorType>>(iconAnchor, true); self.rawLayer->setIconAnchor(mbglValue); @@ -203,6 +209,7 @@ namespace mbgl { - (void)setIconIgnoresPlacement:(NSExpression *)iconIgnoresPlacement { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconIgnoresPlacement: %@", iconIgnoresPlacement); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(iconIgnoresPlacement, false); self.rawLayer->setIconIgnorePlacement(mbglValue); @@ -227,6 +234,7 @@ namespace mbgl { - (void)setIconImageName:(NSExpression *)iconImageName { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconImageName: %@", iconImageName); if (iconImageName && iconImageName.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)iconImageName.constantValue).UTF8String; @@ -259,6 +267,7 @@ namespace mbgl { - (void)setIconOffset:(NSExpression *)iconOffset { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconOffset: %@", iconOffset); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(iconOffset, true); self.rawLayer->setIconOffset(mbglValue); @@ -276,6 +285,7 @@ namespace mbgl { - (void)setIconOptional:(NSExpression *)iconOptional { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconOptional: %@", iconOptional); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(iconOptional, false); self.rawLayer->setIconOptional(mbglValue); @@ -293,6 +303,7 @@ namespace mbgl { - (void)setIconPadding:(NSExpression *)iconPadding { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconPadding: %@", iconPadding); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(iconPadding, false); self.rawLayer->setIconPadding(mbglValue); @@ -310,6 +321,7 @@ namespace mbgl { - (void)setIconPitchAlignment:(NSExpression *)iconPitchAlignment { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconPitchAlignment: %@", iconPitchAlignment); auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLIconPitchAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::AlignmentType>>(iconPitchAlignment, false); self.rawLayer->setIconPitchAlignment(mbglValue); @@ -327,6 +339,7 @@ namespace mbgl { - (void)setIconRotation:(NSExpression *)iconRotation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconRotation: %@", iconRotation); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(iconRotation, true); self.rawLayer->setIconRotate(mbglValue); @@ -351,6 +364,7 @@ namespace mbgl { - (void)setIconRotationAlignment:(NSExpression *)iconRotationAlignment { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconRotationAlignment: %@", iconRotationAlignment); auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLIconRotationAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::AlignmentType>>(iconRotationAlignment, false); self.rawLayer->setIconRotationAlignment(mbglValue); @@ -368,6 +382,7 @@ namespace mbgl { - (void)setIconScale:(NSExpression *)iconScale { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconScale: %@", iconScale); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(iconScale, true); self.rawLayer->setIconSize(mbglValue); @@ -392,6 +407,7 @@ namespace mbgl { - (void)setIconTextFit:(NSExpression *)iconTextFit { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconTextFit: %@", iconTextFit); auto mbglValue = MGLStyleValueTransformer<mbgl::style::IconTextFitType, NSValue *, mbgl::style::IconTextFitType, MGLIconTextFit>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::IconTextFitType>>(iconTextFit, false); self.rawLayer->setIconTextFit(mbglValue); @@ -409,6 +425,7 @@ namespace mbgl { - (void)setIconTextFitPadding:(NSExpression *)iconTextFitPadding { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconTextFitPadding: %@", iconTextFitPadding); auto mbglValue = MGLStyleValueTransformer<std::array<float, 4>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 4>>>(iconTextFitPadding, false); self.rawLayer->setIconTextFitPadding(mbglValue); @@ -426,6 +443,7 @@ namespace mbgl { - (void)setKeepsIconUpright:(NSExpression *)keepsIconUpright { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting keepsIconUpright: %@", keepsIconUpright); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(keepsIconUpright, false); self.rawLayer->setIconKeepUpright(mbglValue); @@ -450,6 +468,7 @@ namespace mbgl { - (void)setKeepsTextUpright:(NSExpression *)keepsTextUpright { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting keepsTextUpright: %@", keepsTextUpright); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(keepsTextUpright, false); self.rawLayer->setTextKeepUpright(mbglValue); @@ -474,6 +493,7 @@ namespace mbgl { - (void)setMaximumTextAngle:(NSExpression *)maximumTextAngle { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting maximumTextAngle: %@", maximumTextAngle); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(maximumTextAngle, false); self.rawLayer->setTextMaxAngle(mbglValue); @@ -498,6 +518,7 @@ namespace mbgl { - (void)setMaximumTextWidth:(NSExpression *)maximumTextWidth { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting maximumTextWidth: %@", maximumTextWidth); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(maximumTextWidth, true); self.rawLayer->setTextMaxWidth(mbglValue); @@ -522,6 +543,7 @@ namespace mbgl { - (void)setSymbolAvoidsEdges:(NSExpression *)symbolAvoidsEdges { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting symbolAvoidsEdges: %@", symbolAvoidsEdges); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(symbolAvoidsEdges, false); self.rawLayer->setSymbolAvoidEdges(mbglValue); @@ -546,6 +568,7 @@ namespace mbgl { - (void)setSymbolPlacement:(NSExpression *)symbolPlacement { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting symbolPlacement: %@", symbolPlacement); auto mbglValue = MGLStyleValueTransformer<mbgl::style::SymbolPlacementType, NSValue *, mbgl::style::SymbolPlacementType, MGLSymbolPlacement>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::SymbolPlacementType>>(symbolPlacement, false); self.rawLayer->setSymbolPlacement(mbglValue); @@ -563,6 +586,7 @@ namespace mbgl { - (void)setSymbolSpacing:(NSExpression *)symbolSpacing { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting symbolSpacing: %@", symbolSpacing); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(symbolSpacing, false); self.rawLayer->setSymbolSpacing(mbglValue); @@ -580,6 +604,7 @@ namespace mbgl { - (void)setSymbolZOrder:(NSExpression *)symbolZOrder { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting symbolZOrder: %@", symbolZOrder); auto mbglValue = MGLStyleValueTransformer<mbgl::style::SymbolZOrderType, NSValue *, mbgl::style::SymbolZOrderType, MGLSymbolZOrder>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::SymbolZOrderType>>(symbolZOrder, false); self.rawLayer->setSymbolZOrder(mbglValue); @@ -597,6 +622,7 @@ namespace mbgl { - (void)setText:(NSExpression *)text { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting text: %@", text); if (text && text.expressionType == NSConstantValueExpressionType) { std::string string = ((NSString *)text.constantValue).UTF8String; @@ -629,6 +655,7 @@ namespace mbgl { - (void)setTextAllowsOverlap:(NSExpression *)textAllowsOverlap { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textAllowsOverlap: %@", textAllowsOverlap); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(textAllowsOverlap, false); self.rawLayer->setTextAllowOverlap(mbglValue); @@ -653,6 +680,7 @@ namespace mbgl { - (void)setTextAnchor:(NSExpression *)textAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textAnchor: %@", textAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::SymbolAnchorType, NSValue *, mbgl::style::SymbolAnchorType, MGLTextAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::SymbolAnchorType>>(textAnchor, true); self.rawLayer->setTextAnchor(mbglValue); @@ -670,6 +698,7 @@ namespace mbgl { - (void)setTextFontNames:(NSExpression *)textFontNames { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textFontNames: %@", textFontNames); auto mbglValue = MGLStyleValueTransformer<std::vector<std::string>, NSArray<NSString *> *, std::string>().toPropertyValue<mbgl::style::PropertyValue<std::vector<std::string>>>(textFontNames, true); self.rawLayer->setTextFont(mbglValue); @@ -694,6 +723,7 @@ namespace mbgl { - (void)setTextFontSize:(NSExpression *)textFontSize { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textFontSize: %@", textFontSize); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textFontSize, true); self.rawLayer->setTextSize(mbglValue); @@ -718,6 +748,7 @@ namespace mbgl { - (void)setTextIgnoresPlacement:(NSExpression *)textIgnoresPlacement { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textIgnoresPlacement: %@", textIgnoresPlacement); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(textIgnoresPlacement, false); self.rawLayer->setTextIgnorePlacement(mbglValue); @@ -742,6 +773,7 @@ namespace mbgl { - (void)setTextJustification:(NSExpression *)textJustification { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textJustification: %@", textJustification); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextJustifyType, NSValue *, mbgl::style::TextJustifyType, MGLTextJustification>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TextJustifyType>>(textJustification, true); self.rawLayer->setTextJustify(mbglValue); @@ -766,6 +798,7 @@ namespace mbgl { - (void)setTextLetterSpacing:(NSExpression *)textLetterSpacing { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textLetterSpacing: %@", textLetterSpacing); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textLetterSpacing, true); self.rawLayer->setTextLetterSpacing(mbglValue); @@ -783,6 +816,7 @@ namespace mbgl { - (void)setTextLineHeight:(NSExpression *)textLineHeight { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textLineHeight: %@", textLineHeight); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textLineHeight, false); self.rawLayer->setTextLineHeight(mbglValue); @@ -800,6 +834,7 @@ namespace mbgl { - (void)setTextOffset:(NSExpression *)textOffset { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textOffset: %@", textOffset); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(textOffset, true); self.rawLayer->setTextOffset(mbglValue); @@ -817,6 +852,7 @@ namespace mbgl { - (void)setTextOptional:(NSExpression *)textOptional { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textOptional: %@", textOptional); auto mbglValue = MGLStyleValueTransformer<bool, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<bool>>(textOptional, false); self.rawLayer->setTextOptional(mbglValue); @@ -834,6 +870,7 @@ namespace mbgl { - (void)setTextPadding:(NSExpression *)textPadding { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textPadding: %@", textPadding); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textPadding, false); self.rawLayer->setTextPadding(mbglValue); @@ -851,6 +888,7 @@ namespace mbgl { - (void)setTextPitchAlignment:(NSExpression *)textPitchAlignment { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textPitchAlignment: %@", textPitchAlignment); auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextPitchAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::AlignmentType>>(textPitchAlignment, false); self.rawLayer->setTextPitchAlignment(mbglValue); @@ -868,6 +906,7 @@ namespace mbgl { - (void)setTextRotation:(NSExpression *)textRotation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textRotation: %@", textRotation); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textRotation, true); self.rawLayer->setTextRotate(mbglValue); @@ -892,6 +931,7 @@ namespace mbgl { - (void)setTextRotationAlignment:(NSExpression *)textRotationAlignment { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textRotationAlignment: %@", textRotationAlignment); auto mbglValue = MGLStyleValueTransformer<mbgl::style::AlignmentType, NSValue *, mbgl::style::AlignmentType, MGLTextRotationAlignment>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::AlignmentType>>(textRotationAlignment, false); self.rawLayer->setTextRotationAlignment(mbglValue); @@ -909,6 +949,7 @@ namespace mbgl { - (void)setTextTransform:(NSExpression *)textTransform { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textTransform: %@", textTransform); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TextTransformType, NSValue *, mbgl::style::TextTransformType, MGLTextTransform>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TextTransformType>>(textTransform, true); self.rawLayer->setTextTransform(mbglValue); @@ -928,6 +969,7 @@ namespace mbgl { - (void)setIconColor:(NSExpression *)iconColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconColor: %@", iconColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(iconColor, true); self.rawLayer->setIconColor(mbglValue); @@ -945,6 +987,7 @@ namespace mbgl { - (void)setIconColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setIconColorTransition(options); @@ -963,6 +1006,7 @@ namespace mbgl { - (void)setIconHaloBlur:(NSExpression *)iconHaloBlur { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconHaloBlur: %@", iconHaloBlur); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(iconHaloBlur, true); self.rawLayer->setIconHaloBlur(mbglValue); @@ -980,6 +1024,7 @@ namespace mbgl { - (void)setIconHaloBlurTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconHaloBlurTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setIconHaloBlurTransition(options); @@ -998,6 +1043,7 @@ namespace mbgl { - (void)setIconHaloColor:(NSExpression *)iconHaloColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconHaloColor: %@", iconHaloColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(iconHaloColor, true); self.rawLayer->setIconHaloColor(mbglValue); @@ -1015,6 +1061,7 @@ namespace mbgl { - (void)setIconHaloColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconHaloColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setIconHaloColorTransition(options); @@ -1033,6 +1080,7 @@ namespace mbgl { - (void)setIconHaloWidth:(NSExpression *)iconHaloWidth { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconHaloWidth: %@", iconHaloWidth); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(iconHaloWidth, true); self.rawLayer->setIconHaloWidth(mbglValue); @@ -1050,6 +1098,7 @@ namespace mbgl { - (void)setIconHaloWidthTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconHaloWidthTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setIconHaloWidthTransition(options); @@ -1068,6 +1117,7 @@ namespace mbgl { - (void)setIconOpacity:(NSExpression *)iconOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconOpacity: %@", iconOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(iconOpacity, true); self.rawLayer->setIconOpacity(mbglValue); @@ -1085,6 +1135,7 @@ namespace mbgl { - (void)setIconOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setIconOpacityTransition(options); @@ -1103,6 +1154,7 @@ namespace mbgl { - (void)setIconTranslation:(NSExpression *)iconTranslation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconTranslation: %@", iconTranslation); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(iconTranslation, false); self.rawLayer->setIconTranslate(mbglValue); @@ -1120,6 +1172,7 @@ namespace mbgl { - (void)setIconTranslationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconTranslationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setIconTranslateTransition(options); @@ -1145,6 +1198,7 @@ namespace mbgl { - (void)setIconTranslationAnchor:(NSExpression *)iconTranslationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting iconTranslationAnchor: %@", iconTranslationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLIconTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(iconTranslationAnchor, false); self.rawLayer->setIconTranslateAnchor(mbglValue); @@ -1169,6 +1223,7 @@ namespace mbgl { - (void)setTextColor:(NSExpression *)textColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textColor: %@", textColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(textColor, true); self.rawLayer->setTextColor(mbglValue); @@ -1186,6 +1241,7 @@ namespace mbgl { - (void)setTextColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setTextColorTransition(options); @@ -1204,6 +1260,7 @@ namespace mbgl { - (void)setTextHaloBlur:(NSExpression *)textHaloBlur { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textHaloBlur: %@", textHaloBlur); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textHaloBlur, true); self.rawLayer->setTextHaloBlur(mbglValue); @@ -1221,6 +1278,7 @@ namespace mbgl { - (void)setTextHaloBlurTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textHaloBlurTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setTextHaloBlurTransition(options); @@ -1239,6 +1297,7 @@ namespace mbgl { - (void)setTextHaloColor:(NSExpression *)textHaloColor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textHaloColor: %@", textHaloColor); auto mbglValue = MGLStyleValueTransformer<mbgl::Color, MGLColor *>().toPropertyValue<mbgl::style::PropertyValue<mbgl::Color>>(textHaloColor, true); self.rawLayer->setTextHaloColor(mbglValue); @@ -1256,6 +1315,7 @@ namespace mbgl { - (void)setTextHaloColorTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textHaloColorTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setTextHaloColorTransition(options); @@ -1274,6 +1334,7 @@ namespace mbgl { - (void)setTextHaloWidth:(NSExpression *)textHaloWidth { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textHaloWidth: %@", textHaloWidth); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textHaloWidth, true); self.rawLayer->setTextHaloWidth(mbglValue); @@ -1291,6 +1352,7 @@ namespace mbgl { - (void)setTextHaloWidthTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textHaloWidthTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setTextHaloWidthTransition(options); @@ -1309,6 +1371,7 @@ namespace mbgl { - (void)setTextOpacity:(NSExpression *)textOpacity { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textOpacity: %@", textOpacity); auto mbglValue = MGLStyleValueTransformer<float, NSNumber *>().toPropertyValue<mbgl::style::PropertyValue<float>>(textOpacity, true); self.rawLayer->setTextOpacity(mbglValue); @@ -1326,6 +1389,7 @@ namespace mbgl { - (void)setTextOpacityTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textOpacityTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setTextOpacityTransition(options); @@ -1344,6 +1408,7 @@ namespace mbgl { - (void)setTextTranslation:(NSExpression *)textTranslation { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textTranslation: %@", textTranslation); auto mbglValue = MGLStyleValueTransformer<std::array<float, 2>, NSValue *>().toPropertyValue<mbgl::style::PropertyValue<std::array<float, 2>>>(textTranslation, false); self.rawLayer->setTextTranslate(mbglValue); @@ -1361,6 +1426,7 @@ namespace mbgl { - (void)setTextTranslationTransition:(MGLTransition )transition { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textTranslationTransition: %@", MGLStringFromMGLTransition(transition)); mbgl::style::TransitionOptions options { { MGLDurationFromTimeInterval(transition.duration) }, { MGLDurationFromTimeInterval(transition.delay) } }; self.rawLayer->setTextTranslateTransition(options); @@ -1386,6 +1452,7 @@ namespace mbgl { - (void)setTextTranslationAnchor:(NSExpression *)textTranslationAnchor { MGLAssertStyleLayerIsValid(); + MGLLogDebug(@"Setting textTranslationAnchor: %@", textTranslationAnchor); auto mbglValue = MGLStyleValueTransformer<mbgl::style::TranslateAnchorType, NSValue *, mbgl::style::TranslateAnchorType, MGLTextTranslationAnchor>().toPropertyValue<mbgl::style::PropertyValue<mbgl::style::TranslateAnchorType>>(textTranslationAnchor, false); self.rawLayer->setTextTranslateAnchor(mbglValue); diff --git a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm index be493bc45d..4b19b76508 100644 --- a/platform/darwin/src/MGLTilePyramidOfflineRegion.mm +++ b/platform/darwin/src/MGLTilePyramidOfflineRegion.mm @@ -8,6 +8,7 @@ #import "MGLTilePyramidOfflineRegion_Private.h" #import "MGLGeometry_Private.h" #import "MGLStyle.h" +#import "MGLLoggingConfiguration_Private.h" #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR #import "MMEConstants.h" @@ -39,6 +40,7 @@ } - (instancetype)init { + MGLLogInfo(@"Calling this initializer is not allowed."); [NSException raise:NSGenericException format: @"-[MGLTilePyramidOfflineRegion init] is unavailable. " @"Use -initWithStyleURL:bounds:fromZoomLevel:toZoomLevel: instead."]; @@ -46,6 +48,7 @@ } - (instancetype)initWithStyleURL:(NSURL *)styleURL bounds:(MGLCoordinateBounds)bounds fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel { + MGLLogDebug(@"Initializing styleURL: %@ bounds: %@ fromZoomLevel: %f toZoomLevel: %f", styleURL, MGLStringFromCoordinateBounds(bounds), minimumZoomLevel, maximumZoomLevel); if (self = [super init]) { if (!styleURL) { styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion]; @@ -87,6 +90,7 @@ } - (nullable instancetype)initWithCoder:(NSCoder *)coder { + MGLLogInfo(@"Initializing with coder."); NSURL *styleURL = [coder decodeObjectForKey:@"styleURL"]; CLLocationCoordinate2D sw = CLLocationCoordinate2DMake([coder decodeDoubleForKey:@"southWestLatitude"], [coder decodeDoubleForKey:@"southWestLongitude"]); diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index 035c6f6593..1cf52f20ce 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -93,6 +93,10 @@ typedef struct __attribute__((objc_boxable)) MGLTransition { NSTimeInterval delay; } MGLTransition; +NS_INLINE NSString *MGLStringFromMGLTransition(MGLTransition transition) { + return [NSString stringWithFormat:@"transition { duration: %f, delay: %f }", transition.duration, transition.delay]; +} + /** Creates a new `MGLTransition` from the given duration and delay. diff --git a/platform/darwin/src/NSArray+MGLAdditions.mm b/platform/darwin/src/NSArray+MGLAdditions.mm index 195e96b09d..c5f25c83b6 100644 --- a/platform/darwin/src/NSArray+MGLAdditions.mm +++ b/platform/darwin/src/NSArray+MGLAdditions.mm @@ -2,6 +2,7 @@ #import "NSDictionary+MGLAdditions.h" #import "NSExpression+MGLPrivateAdditions.h" +#import "MGLLoggingConfiguration_Private.h" @implementation NSArray (MGLAdditions) @@ -28,7 +29,7 @@ NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init]; BOOL isSubsequentItem = NO; for (NSAttributedString *component in self) { - NSAssert([component isKindOfClass:[NSAttributedString class]], @"Items in array must be attributed strings."); + MGLAssert([component isKindOfClass:[NSAttributedString class]], @"Items in array must be attributed strings."); if (isSubsequentItem) { [attributedString appendAttributedString:attributedSeparator]; } diff --git a/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm b/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm index a8ae19b172..5eb20da846 100644 --- a/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm +++ b/platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm @@ -4,6 +4,7 @@ #import "NSPredicate+MGLPrivateAdditions.h" #import "NSExpression+MGLPrivateAdditions.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/conversion/property_value.hpp> @@ -25,7 +26,7 @@ - (id)mgl_jsonExpressionObject { switch (self.compoundPredicateType) { case NSNotPredicateType: { - NSAssert(self.subpredicates.count <= 1, @"NOT predicate cannot have multiple subpredicates."); + MGLAssert(self.subpredicates.count <= 1, @"NOT predicate cannot have multiple subpredicates."); NSPredicate *subpredicate = self.subpredicates.firstObject; return @[@"!", subpredicate.mgl_jsonExpressionObject]; } diff --git a/platform/darwin/src/NSException+MGLAdditions.h b/platform/darwin/src/NSException+MGLAdditions.h index f75b54c15c..274ca50a89 100644 --- a/platform/darwin/src/NSException+MGLAdditions.h +++ b/platform/darwin/src/NSException+MGLAdditions.h @@ -1,3 +1,4 @@ #import <Foundation/Foundation.h> +#import "MGLLoggingConfiguration_Private.h" -#define MGLAssertIsMainThread() NSAssert([[NSThread currentThread] isMainThread], @"%s must be accessed on the main thread, not %@", __PRETTY_FUNCTION__, [NSThread currentThread]) +#define MGLAssertIsMainThread() MGLAssert([[NSThread currentThread] isMainThread], @"%s must be accessed on the main thread, not %@", __PRETTY_FUNCTION__, [NSThread currentThread]) diff --git a/platform/darwin/src/NSPredicate+MGLAdditions.mm b/platform/darwin/src/NSPredicate+MGLAdditions.mm index d01b2c8f83..436402c9e0 100644 --- a/platform/darwin/src/NSPredicate+MGLAdditions.mm +++ b/platform/darwin/src/NSPredicate+MGLAdditions.mm @@ -2,6 +2,7 @@ #import "MGLValueEvaluator.h" #import "MGLStyleValue_Private.h" +#import "MGLLoggingConfiguration_Private.h" #include <mbgl/style/conversion/filter.hpp> @@ -63,7 +64,7 @@ static NSDictionary * const MGLPredicateOperatorTypesByJSONOperator = @{ return [NSPredicate predicateWithValue:NO]; } - NSAssert([object isKindOfClass:[NSArray class]], @"Condition for case expression should be an expression."); + MGLAssert([object isKindOfClass:[NSArray class]], @"Condition for case expression should be an expression."); NSArray *objects = (NSArray *)object; NSString *op = objects.firstObject; @@ -74,10 +75,10 @@ static NSDictionary * const MGLPredicateOperatorTypesByJSONOperator = @{ NSComparisonPredicateOptions options = 0; if (objects.count > 3) { NSArray *collatorExpression = objects[3]; - NSCAssert([collatorExpression isKindOfClass:[NSArray class]], @"Collators must be dictionaries."); - NSCAssert(collatorExpression.count == 2, @"Malformed collator expression"); + MGLCAssert([collatorExpression isKindOfClass:[NSArray class]], @"Collators must be dictionaries."); + MGLCAssert(collatorExpression.count == 2, @"Malformed collator expression"); NSDictionary *collator = collatorExpression[1]; - NSCAssert([collator isKindOfClass:[NSDictionary class]], @"Malformed collator in collator expression"); + MGLCAssert([collator isKindOfClass:[NSDictionary class]], @"Malformed collator in collator expression"); // Predicate options can’t express specific locales as collators can. if (!collator[@"locale"]) { diff --git a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm index a41950b6b3..e2cde278f4 100644 --- a/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm +++ b/platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm @@ -1,5 +1,6 @@ #import "NSValue+MGLStyleAttributeAdditions.h" #import "MGLLight.h" +#import "MGLLoggingConfiguration_Private.h" #if TARGET_OS_IPHONE #import <UIKit/UIKit.h> #define MGLEdgeInsets UIEdgeInsets @@ -35,7 +36,7 @@ - (std::array<float, 2>)mgl_offsetArrayValue { - NSAssert(strcmp(self.objCType, @encode(CGVector)) == 0, @"Value does not represent a CGVector"); + MGLAssert(strcmp(self.objCType, @encode(CGVector)) == 0, @"Value does not represent a CGVector"); CGVector vector; [self getValue:&vector]; #if !TARGET_OS_IPHONE @@ -49,7 +50,7 @@ - (std::array<float, 4>)mgl_paddingArrayValue { - NSAssert(strcmp(self.objCType, @encode(MGLEdgeInsets)) == 0, @"Value does not represent an NSEdgeInsets/UIEdgeInsets"); + MGLAssert(strcmp(self.objCType, @encode(MGLEdgeInsets)) == 0, @"Value does not represent an NSEdgeInsets/UIEdgeInsets"); MGLEdgeInsets insets; [self getValue:&insets]; // Style specification defines padding in clockwise order: top, right, bottom, left. @@ -63,7 +64,7 @@ - (std::array<float, 3>)mgl_lightPositionArrayValue { - NSAssert(strcmp(self.objCType, @encode(MGLSphericalPosition)) == 0, @"Value does not represent an MGLSphericalPosition"); + MGLAssert(strcmp(self.objCType, @encode(MGLSphericalPosition)) == 0, @"Value does not represent an MGLSphericalPosition"); MGLSphericalPosition lightPosition; [self getValue:&lightPosition]; // Style specification defines padding in clockwise order: top, right, bottom, left. diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index 4a16ad82fb..9726f6064f 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -7,6 +7,7 @@ #include <mbgl/util/version.hpp> #import <Foundation/Foundation.h> +#import "MGLLoggingConfiguration_Private.h" #include <mutex> #include <chrono> @@ -202,6 +203,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, @autoreleasepool { NSURL* url = [NSURL URLWithString:@(resource.url.c_str())]; + MGLLogDebug(@"Requesting URI: %@", url.relativePath); if (impl->accountType == 0 && ([url.host isEqualToString:@"mapbox.com"] || [url.host hasSuffix:@".mapbox.com"])) { NSString* absoluteString = [url.absoluteString @@ -231,6 +233,8 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, using Error = Response::Error; if (error) { + MGLLogError(@"Requesting: %@ failed with error: %@", res.URL.relativePath, error); + if (data) { response.data = std::make_shared<std::string>((const char*)[data bytes], [data length]); @@ -262,6 +266,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, } } else if ([res isKindOfClass:[NSHTTPURLResponse class]]) { const long responseCode = [(NSHTTPURLResponse *)res statusCode]; + MGLLogDebug(@"Requesting %@ returned responseCode: %lu", res.URL.relativePath, responseCode); NSDictionary *headers = [(NSHTTPURLResponse *)res allHeaderFields]; NSString *cache_control = [headers objectForKey:@"Cache-Control"]; diff --git a/platform/ios/app/MBXAppDelegate.m b/platform/ios/app/MBXAppDelegate.m index e7fe204183..9932356e6e 100644 --- a/platform/ios/app/MBXAppDelegate.m +++ b/platform/ios/app/MBXAppDelegate.m @@ -21,7 +21,9 @@ NSString * const MBXMapboxAccessTokenDefaultsKey = @"MBXMapboxAccessToken"; accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:MBXMapboxAccessTokenDefaultsKey]; } [MGLAccountManager setAccessToken:accessToken]; - [MGLLoggingConfiguration sharedConfiguration].loggingLevel = MGLLoggingLevelDebug; +#ifndef MGL_DISABLE_LOGGING + [MGLLoggingConfiguration sharedConfiguration].loggingLevel = MGLLoggingLevelFault; +#endif } return YES; diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 2f7ac3b663..78acfb46ec 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -3620,6 +3620,8 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ""; + "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = ""; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; diff --git a/platform/ios/src/MGLAnnotationImage.m b/platform/ios/src/MGLAnnotationImage.m index 3b89b19bd8..31b67c7a3c 100644 --- a/platform/ios/src/MGLAnnotationImage.m +++ b/platform/ios/src/MGLAnnotationImage.m @@ -1,4 +1,5 @@ #import "MGLAnnotationImage_Private.h" +#import "MGLLoggingConfiguration_Private.h" @interface MGLAnnotationImage () @@ -18,6 +19,7 @@ - (instancetype)initWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier { + MGLLogDebug(@"Initializing with image size: %@ reuseIdentifier: %@", NSStringFromCGSize(image.size), reuseIdentifier); self = [super init]; if (self) @@ -35,6 +37,7 @@ } - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder."); if (self = [super init]) { _image = [decoder decodeObjectOfClass:[UIImage class] forKey:@"image"]; _reuseIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"reuseIdentifier"]; @@ -66,6 +69,7 @@ } - (void)setImage:(UIImage *)image { + MGLLogDebug(@"Setting image: %@", image); _image = image; [self.delegate annotationImageNeedsRedisplay:self]; } diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm index 46b0f56a79..5f76dbff5c 100644 --- a/platform/ios/src/MGLAnnotationView.mm +++ b/platform/ios/src/MGLAnnotationView.mm @@ -2,6 +2,7 @@ #import "MGLAnnotationView_Private.h" #import "MGLMapView_Private.h" #import "MGLAnnotation.h" +#import "MGLLoggingConfiguration_Private.h" #import "NSBundle+MGLAdditions.h" @@ -27,6 +28,7 @@ } - (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier { + MGLLogDebug(@"Initializing with identifier: %@", reuseIdentifier); self = [super initWithFrame:CGRectZero]; if (self) { [self commonInitWithAnnotation:nil reuseIdentifier:reuseIdentifier]; @@ -35,6 +37,7 @@ } - (instancetype)initWithAnnotation:(nullable id<MGLAnnotation>)annotation reuseIdentifier:(nullable NSString *)reuseIdentifier { + MGLLogDebug(@"Initializing with annotation: %@ reuseIdentifier: %@", annotation, reuseIdentifier); self = [super initWithFrame:CGRectZero]; if (self) { [self commonInitWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; @@ -51,6 +54,7 @@ } - (instancetype)initWithCoder:(NSCoder *)decoder { + MGLLogInfo(@"Initializing with coder."); if (self = [super initWithCoder:decoder]) { _reuseIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"reuseIdentifier"]; _annotation = [decoder decodeObjectOfClass:[NSObject class] forKey:@"annotation"]; @@ -83,17 +87,20 @@ - (void)setCenterOffset:(CGVector)centerOffset { + MGLLogDebug(@"Setting centerOffset: %@", NSStringFromCGVector(centerOffset)); _centerOffset = centerOffset; self.center = self.center; } - (void)setSelected:(BOOL)selected { + MGLLogDebug(@"Setting selected: %@", MGLStringFromBOOL(selected)); [self setSelected:selected animated:NO]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { + MGLLogDebug(@"Setting selected: %@ animated: %@", MGLStringFromBOOL(selected), MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"selected"]; _selected = selected; [self didChangeValueForKey:@"selected"]; @@ -109,6 +116,7 @@ - (void)setCenter:(CGPoint)center { + MGLLogDebug(@"Setting center: %@", NSStringFromCGPoint(center)); center.x += _centerOffset.dx; center.y += _centerOffset.dy; @@ -119,6 +127,7 @@ - (void)setScalesWithViewingDistance:(BOOL)scalesWithViewingDistance { + MGLLogDebug(@"Setting scaleWithViewingDistance: %@", MGLStringFromBOOL(scalesWithViewingDistance)); if (_scalesWithViewingDistance != scalesWithViewingDistance) { _scalesWithViewingDistance = scalesWithViewingDistance; @@ -171,6 +180,7 @@ - (void)setRotatesToMatchCamera:(BOOL)rotatesToMatchCamera { + MGLLogDebug(@"Setting rotatesToMatchCamera: %@", MGLStringFromBOOL(rotatesToMatchCamera)); if (_rotatesToMatchCamera != rotatesToMatchCamera) { _rotatesToMatchCamera = rotatesToMatchCamera; @@ -202,6 +212,7 @@ - (void)setDraggable:(BOOL)draggable { + MGLLogDebug(@"Setting draggable: %@", MGLStringFromBOOL(draggable)); [self willChangeValueForKey:@"draggable"]; _draggable = draggable; [self didChangeValueForKey:@"draggable"]; @@ -275,11 +286,13 @@ - (void)setDragState:(MGLAnnotationViewDragState)dragState { + MGLLogDebug(@"Setting dragState: %lu", (unsigned long)dragState); [self setDragState:dragState animated:YES]; } - (void)setDragState:(MGLAnnotationViewDragState)dragState animated:(BOOL)animated { + MGLLogDebug(@"Setting dragState: %lu animated: %@", (unsigned long)dragState, MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"dragState"]; _dragState = dragState; [self didChangeValueForKey:@"dragState"]; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index a7046e2505..4880a63cb9 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -318,8 +318,11 @@ public: { if (self = [super initWithFrame:frame]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + MGLLogDebug(@"Initializing frame: %@", NSStringFromCGRect(frame)); [self commonInit]; self.styleURL = nil; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } @@ -328,8 +331,11 @@ public: { if (self = [super initWithFrame:frame]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + MGLLogDebug(@"Initializing frame: %@ styleURL: %@", NSStringFromCGRect(frame), styleURL); [self commonInit]; self.styleURL = styleURL; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } @@ -338,8 +344,10 @@ public: { if (self = [super initWithCoder:decoder]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); [self commonInit]; self.styleURL = nil; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } @@ -365,7 +373,7 @@ public: - (nonnull NSURL *)styleURL { NSString *styleURLString = @(_mbglMap->getStyle().getURL().c_str()).mgl_stringOrNilIfEmpty; - NSAssert(styleURLString || _isTargetingInterfaceBuilder, @"Invalid style URL string %@", styleURLString); + MGLAssert(styleURLString || _isTargetingInterfaceBuilder, @"Invalid style URL string %@", styleURLString); return styleURLString ? [NSURL URLWithString:styleURLString] : nil; } @@ -384,6 +392,7 @@ public: } - (IBAction)reloadStyle:(__unused id)sender { + MGLLogInfo(@"Reloading style."); NSURL *styleURL = self.styleURL; _mbglMap->getStyle().loadURL(""); self.styleURL = styleURL; @@ -401,7 +410,6 @@ public: - (void)commonInit { - MGLLogInfo(@"Initializing."); _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; _opaque = NO; @@ -601,8 +609,6 @@ public: [MGLMapboxEvents pushEvent:MMEEventTypeMapLoad withAttributes:@{}]; } - MGLLogInfo(@"Initialization completed."); - } - (mbgl::Size)size @@ -627,7 +633,7 @@ public: // create context // _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - NSAssert(_context, @"Failed to create OpenGL ES context."); + MGLAssert(_context, @"Failed to create OpenGL ES context."); // create GL view // @@ -682,6 +688,7 @@ public: - (void)dealloc { + MGLLogInfo(@"Deallocating MGLMapView."); [_reachability stopNotifier]; [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; @@ -729,11 +736,11 @@ public: [_locationManager stopUpdatingLocation]; [_locationManager stopUpdatingHeading]; _locationManager.delegate = nil; - } - (void)setDelegate:(nullable id<MGLMapViewDelegate>)delegate { + MGLLogDebug(@"Setting delegate: %@", delegate); if (_delegate == delegate) return; _delegate = delegate; @@ -1260,6 +1267,7 @@ public: - (void)sleepGL:(__unused NSNotification *)notification { + MGLLogInfo(@"Entering background."); MGLAssertIsMainThread(); // Ideally we would wait until we actually received a memory warning but the bulk of the memory @@ -1304,6 +1312,7 @@ public: - (void)wakeGL:(__unused NSNotification *)notification { + MGLLogInfo(@"Entering foreground."); MGLAssertIsMainThread(); if (self.dormant && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) @@ -1389,7 +1398,7 @@ public: - (void)notifyGestureDidEndWithDrift:(BOOL)drift { _changeDelimiterSuppressionDepth--; - NSAssert(_changeDelimiterSuppressionDepth >= 0, + MGLAssert(_changeDelimiterSuppressionDepth >= 0, @"Unbalanced change delimiter suppression/unsuppression"); if (_changeDelimiterSuppressionDepth == 0) { _mbglMap->setGestureInProgress(false); @@ -1770,7 +1779,7 @@ public: if (hitAnnotationTag != _selectedAnnotationTag) { id <MGLAnnotation> annotation = [self annotationWithTag:hitAnnotationTag]; - NSAssert(annotation, @"Cannot select nonexistent annotation with tag %llu", hitAnnotationTag); + MGLAssert(annotation, @"Cannot select nonexistent annotation with tag %llu", hitAnnotationTag); return annotation; } } @@ -2012,9 +2021,9 @@ public: { if ([self.delegate respondsToSelector:@selector(mapView:annotation:calloutAccessoryControlTapped:)]) { - NSAssert([tap.view isKindOfClass:[UIControl class]], @"Tapped view %@ is not a UIControl", tap.view); + MGLAssert([tap.view isKindOfClass:[UIControl class]], @"Tapped view %@ is not a UIControl", tap.view); id <MGLAnnotation> selectedAnnotation = self.selectedAnnotation; - NSAssert(selectedAnnotation, @"Selected annotation should not be nil."); + MGLAssert(selectedAnnotation, @"Selected annotation should not be nil."); [self.delegate mapView:self annotation:selectedAnnotation calloutAccessoryControlTapped:(UIControl *)tap.view]; } @@ -2030,7 +2039,7 @@ public: if ([self.delegate respondsToSelector:@selector(mapView:tapOnCalloutForAnnotation:)]) { id <MGLAnnotation> selectedAnnotation = self.selectedAnnotation; - NSAssert(selectedAnnotation, @"Selected annotation should not be nil."); + MGLAssert(selectedAnnotation, @"Selected annotation should not be nil."); [self.delegate mapView:self tapOnCalloutForAnnotation:selectedAnnotation]; } } @@ -2040,7 +2049,7 @@ public: if ([self.delegate respondsToSelector:@selector(mapView:tapOnCalloutForAnnotation:)]) { id <MGLAnnotation> selectedAnnotation = self.selectedAnnotation; - NSAssert(selectedAnnotation, @"Selected annotation should not be nil."); + MGLAssert(selectedAnnotation, @"Selected annotation should not be nil."); [self.delegate mapView:self tapOnCalloutForAnnotation:selectedAnnotation]; } } @@ -2389,6 +2398,7 @@ public: - (void)resetNorth { + MGLLogInfo(@"Resetting the map rotation to a northern heading — a direction of 0 degrees."); [self resetNorthAnimated:YES]; } @@ -2399,6 +2409,7 @@ public: - (void)resetPosition { + MGLLogInfo(@"Resetting the map to the current style’s default viewport."); auto camera = _mbglMap->getStyle().getDefaultCamera(); CGFloat pitch = *camera.pitch; CLLocationDirection heading = mbgl::util::wrap(*camera.angle, 0., 360.); @@ -2411,6 +2422,7 @@ public: - (void)setZoomEnabled:(BOOL)zoomEnabled { + MGLLogDebug(@"Setting zoomEnabled: %@", MGLStringFromBOOL(zoomEnabled)); _zoomEnabled = zoomEnabled; self.pinch.enabled = zoomEnabled; self.doubleTap.enabled = zoomEnabled; @@ -2420,24 +2432,28 @@ public: - (void)setScrollEnabled:(BOOL)scrollEnabled { + MGLLogDebug(@"Setting scrollEnabled: %@", MGLStringFromBOOL(scrollEnabled)); _scrollEnabled = scrollEnabled; self.pan.enabled = scrollEnabled; } - (void)setRotateEnabled:(BOOL)rotateEnabled { + MGLLogDebug(@"Setting rotateEnabled: %@", MGLStringFromBOOL(rotateEnabled)); _rotateEnabled = rotateEnabled; self.rotate.enabled = rotateEnabled; } - (void)setPitchEnabled:(BOOL)pitchEnabled { + MGLLogDebug(@"Setting pitchEnabled: %@", MGLStringFromBOOL(pitchEnabled)); _pitchEnabled = pitchEnabled; self.twoFingerDrag.enabled = pitchEnabled; } - (void)setShowsScale:(BOOL)showsScale { + MGLLogDebug(@"Setting showsScale: %@", MGLStringFromBOOL(showsScale)); _showsScale = showsScale; self.scaleBar.hidden = !showsScale; @@ -2605,7 +2621,7 @@ public: NSUInteger annotationIndex = index - visibleAnnotationRange.location; MGLAnnotationTag annotationTag = visibleAnnotations[annotationIndex]; - NSAssert(annotationTag != MGLAnnotationTagNotFound, @"Can’t get accessibility element for nonexistent or invisible annotation at index %li.", (long)index); + MGLAssert(annotationTag != MGLAnnotationTagNotFound, @"Can’t get accessibility element for nonexistent or invisible annotation at index %li.", (long)index); return [self accessibilityElementForAnnotationWithTag:annotationTag]; } @@ -2650,7 +2666,7 @@ public: return self.attributionButton; } - NSAssert(NO, @"Index %ld not in recognized accessibility element ranges. " + MGLAssert(NO, @"Index %ld not in recognized accessibility element ranges. " @"User location annotation range: %@; visible annotation range: %@; " @"visible place feature range: %@; visible road feature range: %@.", (long)index, NSStringFromRange(userLocationAnnotationRange), @@ -2666,7 +2682,7 @@ public: */ - (id)accessibilityElementForAnnotationWithTag:(MGLAnnotationTag)annotationTag { - NSAssert(_annotationContextsByAnnotationTag.count(annotationTag), @"Missing annotation for tag %llu.", annotationTag); + MGLAssert(_annotationContextsByAnnotationTag.count(annotationTag), @"Missing annotation for tag %llu.", annotationTag); MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); id <MGLAnnotation> annotation = annotationContext.annotation; @@ -2983,11 +2999,13 @@ public: - (void)setCenterCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated { + MGLLogDebug(@"Setting centerCoordinate: %@ animated: %@", MGLStringFromCLLocationCoordinate2D(coordinate), MGLStringFromBOOL(animated)); [self setCenterCoordinate:coordinate zoomLevel:self.zoomLevel animated:animated]; } - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate { + MGLLogDebug(@"Setting centerCoordinate: %@", MGLStringFromCLLocationCoordinate2D(centerCoordinate)); [self setCenterCoordinate:centerCoordinate animated:NO]; } @@ -2999,15 +3017,31 @@ public: - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel animated:(BOOL)animated { + MGLLogDebug(@"Setting centerCoordinate: %@ zoomLevel: %f animated: %@", + MGLStringFromCLLocationCoordinate2D(centerCoordinate), + zoomLevel, + MGLStringFromBOOL(animated)); [self setCenterCoordinate:centerCoordinate zoomLevel:zoomLevel direction:self.direction animated:animated]; } -- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated { +- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated +{ + MGLLogDebug(@"Setting centerCoordinate: %@ zoomLevel: %f direction: %f animated: %@", + MGLStringFromCLLocationCoordinate2D(centerCoordinate), + zoomLevel, + direction, + MGLStringFromBOOL(animated)); [self setCenterCoordinate:centerCoordinate zoomLevel:zoomLevel direction:direction animated:animated completionHandler:NULL]; } - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting centerCoordinate: %@ zoomLevel: %f direction: %f animated: %@ completionHandler: %@", + MGLStringFromCLLocationCoordinate2D(centerCoordinate), + zoomLevel, + direction, + MGLStringFromBOOL(animated), + completion); self.userTrackingMode = MGLUserTrackingModeNone; self.cameraChangeReasonBitmask |= MGLCameraChangeReasonProgrammatic; @@ -3079,11 +3113,13 @@ public: - (void)setZoomLevel:(double)zoomLevel { + MGLLogDebug(@"Setting zoomLevel: %f", zoomLevel); [self setZoomLevel:zoomLevel animated:NO]; } - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated { + MGLLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MGLStringFromBOOL(animated)); if (zoomLevel == self.zoomLevel) return; [self cancelTransitions]; @@ -3098,6 +3134,7 @@ public: - (void)setMinimumZoomLevel:(double)minimumZoomLevel { + MGLLogDebug(@"Setting minimumZoomLevel: %f", minimumZoomLevel); _mbglMap->setMinZoom(minimumZoomLevel); } @@ -3108,6 +3145,7 @@ public: - (void)setMaximumZoomLevel:(double)maximumZoomLevel { + MGLLogDebug(@"Setting maximumZoomLevel: %f", maximumZoomLevel); _mbglMap->setMaxZoom(maximumZoomLevel); } @@ -3123,16 +3161,22 @@ public: - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@", MGLStringFromCoordinateBounds(bounds)); [self setVisibleCoordinateBounds:bounds animated:NO]; } - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds animated:(BOOL)animated { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@ animated: %@", MGLStringFromCoordinateBounds(bounds), MGLStringFromBOOL(animated)); [self setVisibleCoordinateBounds:bounds edgePadding:UIEdgeInsetsZero animated:animated]; } - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@ edgePadding: %@ animated: %@", + MGLStringFromCoordinateBounds(bounds), + NSStringFromUIEdgeInsets(insets), + MGLStringFromBOOL(animated)); CLLocationCoordinate2D coordinates[] = { {bounds.ne.latitude, bounds.sw.longitude}, bounds.sw, @@ -3147,6 +3191,11 @@ public: - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction animated:(BOOL)animated { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@ edgePadding: %@ direction: %f animated: %@", + MGLStringFromCoordinateBounds(bounds), + NSStringFromUIEdgeInsets(insets), + direction, + MGLStringFromBOOL(animated)); CLLocationCoordinate2D coordinates[] = { {bounds.ne.latitude, bounds.sw.longitude}, bounds.sw, @@ -3162,20 +3211,36 @@ public: - (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated { + MGLLogDebug(@"Setting: %lu coordinates edgePadding: %@ animated: %@", + count, + NSStringFromUIEdgeInsets(insets), + MGLStringFromBOOL(animated)); [self setVisibleCoordinates:coordinates count:count edgePadding:insets direction:self.direction animated:animated]; } - (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction animated:(BOOL)animated { + MGLLogDebug(@"Setting: %lu coordinates edgePadding: %@ direction: %f animated: %@", + count, + NSStringFromUIEdgeInsets(insets), + direction, + MGLStringFromBOOL(animated)); [self setVisibleCoordinates:coordinates count:count edgePadding:insets direction:direction duration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil]; } - (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function { + MGLLogDebug(@"Setting: %lu coordinates edgePadding: %@ direction: %f duration: %f animationTimingFunction: %@", + count, + NSStringFromUIEdgeInsets(insets), + direction, + duration, + function); [self setVisibleCoordinates:coordinates count:count edgePadding:insets direction:direction duration:duration animationTimingFunction:function completionHandler:NULL]; } - (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets direction:(CLLocationDirection)direction duration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting: %lu coordinates edgePadding: %@ direction: %f duration: %f animationTimingFunction: %@ completionHandler: %@", count, NSStringFromUIEdgeInsets(insets), direction, duration, function, completion); self.userTrackingMode = MGLUserTrackingModeNone; self.cameraChangeReasonBitmask |= MGLCameraChangeReasonProgrammatic; @@ -3248,6 +3313,7 @@ public: - (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated { + MGLLogDebug(@"Setting direction: %f animated: %@", direction, MGLStringFromBOOL(animated)); if ( ! animated && ! self.rotationAllowed) return; if (self.userTrackingMode == MGLUserTrackingModeFollowWithHeading) @@ -3283,6 +3349,7 @@ public: - (void)setDirection:(CLLocationDirection)direction { + MGLLogDebug(@"Setting direction: %f", direction); [self setDirection:direction animated:NO]; } @@ -3304,25 +3371,30 @@ public: - (void)setCamera:(MGLMapCamera *)camera { + MGLLogDebug(@"Setting camera: %@", camera); [self setCamera:camera animated:NO]; } - (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated { + MGLLogDebug(@"Setting camera: %@ animated: %@", camera, MGLStringFromBOOL(animated)); [self setCamera:camera withDuration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function { + MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@", camera, duration, function); [self setCamera:camera withDuration:duration animationTimingFunction:function completionHandler:NULL]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@ completionHandler: %@", camera, duration, function, completion); [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:self.contentInset completionHandler:completion]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function edgePadding:(UIEdgeInsets)edgePadding completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@ edgePadding: %@ completionHandler: %@", camera, duration, function, NSStringFromUIEdgeInsets(edgePadding), completion); mbgl::AnimationOptions animationOptions; if (duration > 0) { @@ -3361,16 +3433,19 @@ public: - (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ completionHandler: %@", camera, completion); [self flyToCamera:camera withDuration:-1 completionHandler:completion]; } - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ withDuration: %f completionHandler: %@", camera, duration, completion); [self flyToCamera:camera withDuration:duration peakAltitude:-1 completionHandler:completion]; } - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ withDuration: %f peakAltitude: %f completionHandler: %@", camera, duration, peakAltitude, completion); [self _flyToCamera:camera edgePadding:self.contentInset withDuration:duration peakAltitude:peakAltitude completionHandler:completion]; } @@ -3667,7 +3742,7 @@ public: } MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); - NSAssert(annotationContext.annotation, @"Missing annotation for tag %llu.", annotationTag); + MGLAssert(annotationContext.annotation, @"Missing annotation for tag %llu.", annotationTag); if (annotationContext.annotation) { [annotations addObject:annotationContext.annotation]; @@ -3706,6 +3781,7 @@ public: - (void)addAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Adding annotation: %@", annotation); if ( ! annotation) return; // The core bulk add API is efficient with respect to indexing and @@ -3716,6 +3792,7 @@ public: - (void)addAnnotations:(NSArray<id <MGLAnnotation>> *)annotations { + MGLLogDebug(@"Adding: %lu annotations", annotations.count); if ( ! annotations) return; [self willChangeValueForKey:@"annotations"]; @@ -3729,7 +3806,7 @@ public: for (id <MGLAnnotation> annotation in annotations) { - NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation"); + MGLAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation"); // adding the same annotation object twice is a no-op if (_annotationTagsByAnnotation.count(annotation) != 0) @@ -3833,7 +3910,7 @@ public: _annotationContextsByAnnotationTag[annotationTag] = context; if ([annotation isKindOfClass:[NSObject class]]) { - NSAssert(![annotation isKindOfClass:[MGLMultiPoint class]], @"Point annotation should not be MGLMultiPoint."); + MGLAssert(![annotation isKindOfClass:[MGLMultiPoint class]], @"Point annotation should not be MGLMultiPoint."); [(NSObject *)annotation addObserver:self forKeyPath:@"coordinate" options:0 context:(void *)(NSUInteger)annotationTag]; } } @@ -3939,6 +4016,7 @@ public: - (nullable MGLAnnotationView *)viewForAnnotation:(id<MGLAnnotation>)annotation { + MGLLogDebug(@"Retrieving the annotation view for: %@", annotation); if (annotation == self.userLocation) { return self.userLocationAnnotationView; @@ -4005,6 +4083,7 @@ public: - (void)removeAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Removing annotation: %@", annotation); if ( ! annotation) return; // The core bulk deletion API is efficient with respect to indexing @@ -4016,13 +4095,14 @@ public: - (void)removeAnnotations:(NSArray<id <MGLAnnotation>> *)annotations { + MGLLogDebug(@"Removing: %lu annotations", annotations.count); if ( ! annotations) return; [self willChangeValueForKey:@"annotations"]; for (id <MGLAnnotation> annotation in annotations) { - NSAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation"); + MGLAssert([annotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation"); MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation]; if (annotationTag == MGLAnnotationTagNotFound) @@ -4093,15 +4173,17 @@ public: - (void)addOverlay:(id <MGLOverlay>)overlay { + MGLLogDebug(@"Adding overlay: %@", overlay); [self addOverlays:@[ overlay ]]; } - (void)addOverlays:(NSArray<id <MGLOverlay>> *)overlays { + MGLLogDebug(@"Adding: %lu overlays", overlays.count); #if DEBUG for (id <MGLOverlay> overlay in overlays) { - NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"overlay should conform to MGLOverlay"); + MGLAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"overlay should conform to MGLOverlay"); } #endif @@ -4110,15 +4192,17 @@ public: - (void)removeOverlay:(id <MGLOverlay>)overlay { + MGLLogDebug(@"Removing overlay: %@", overlay); [self removeOverlays:@[ overlay ]]; } - (void)removeOverlays:(NSArray<id <MGLOverlay>> *)overlays { + MGLLogDebug(@"Removing: %lu overlays", overlays.count); #if DEBUG for (id <MGLOverlay> overlay in overlays) { - NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"overlay should conform to MGLOverlay"); + MGLAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"overlay should conform to MGLOverlay"); } #endif @@ -4180,7 +4264,7 @@ public: // hit testing fails. auto end = std::remove_if(nearbyAnnotations.begin(), nearbyAnnotations.end(), [&](const MGLAnnotationTag annotationTag) { id <MGLAnnotation> annotation = [self annotationWithTag:annotationTag]; - NSAssert(annotation, @"Unknown annotation found nearby tap"); + MGLAssert(annotation, @"Unknown annotation found nearby tap"); if ( ! annotation) { return true; @@ -4349,6 +4433,7 @@ public: - (void)setSelectedAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Selecting annotation: %@", annotation); [self willChangeValueForKey:@"selectedAnnotations"]; _selectedAnnotationTag = [self annotationTagForAnnotation:annotation]; _userLocationAnnotationIsSelected = annotation && annotation == self.userLocation; @@ -4363,11 +4448,12 @@ public: - (void)setSelectedAnnotations:(NSArray<id <MGLAnnotation>> *)selectedAnnotations { + MGLLogDebug(@"Selecting: %lu annotations", selectedAnnotations.count); if ( ! selectedAnnotations.count) return; id <MGLAnnotation> firstAnnotation = selectedAnnotations[0]; - NSAssert([firstAnnotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation"); + MGLAssert([firstAnnotation conformsToProtocol:@protocol(MGLAnnotation)], @"annotation should conform to MGLAnnotation"); if ([firstAnnotation isKindOfClass:[MGLMultiPoint class]]) return; @@ -4376,6 +4462,7 @@ public: - (void)selectAnnotation:(id <MGLAnnotation>)annotation animated:(BOOL)animated { + MGLLogDebug(@"Selecting annotation: %@ animated: %@", annotation, MGLStringFromBOOL(animated)); CGRect positioningRect = [self positioningRectForAnnotation:annotation defaultCalloutPoint:CGPointZero]; [self selectAnnotation:annotation moveOnscreen:animated animateSelection:YES calloutPositioningRect:positioningRect]; } @@ -4448,7 +4535,7 @@ public: if (![providedCalloutView isKindOfClass:[UIView class]]) { [NSException raise:NSInvalidArgumentException format:@"Callout view must be a kind of UIView"]; } - NSAssert([providedCalloutView conformsToProtocol:@protocol(MGLCalloutView)], @"callout view must conform to MGLCalloutView"); + MGLAssert([providedCalloutView conformsToProtocol:@protocol(MGLCalloutView)], @"callout view must conform to MGLCalloutView"); calloutView = providedCalloutView; } } @@ -4660,6 +4747,7 @@ public: if (self.selectedAnnotation == annotation) { + MGLLogDebug(@"Deselecting annotation: %@ animated: %@", annotation, MGLStringFromBOOL(animated)); // dismiss popup [self.calloutViewForSelectedAnnotation dismissCalloutAnimated:animated]; @@ -4730,6 +4818,7 @@ public: - (void)showAnnotations:(NSArray<id <MGLAnnotation>> *)annotations animated:(BOOL)animated { + MGLLogDebug(@"Showing: %lu annotations animated: %@", annotations.count, MGLStringFromBOOL(animated)); CGFloat maximumPadding = 100; CGFloat yPadding = (self.frame.size.height / 5 <= maximumPadding) ? (self.frame.size.height / 5) : maximumPadding; CGFloat xPadding = (self.frame.size.width / 5 <= maximumPadding) ? (self.frame.size.width / 5) : maximumPadding; @@ -4741,6 +4830,7 @@ public: - (void)showAnnotations:(NSArray<id <MGLAnnotation>> *)annotations edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated { + MGLLogDebug(@"Showing: %lu annotations edgePadding: %@ animated: %@", annotations.count, NSStringFromUIEdgeInsets(insets), MGLStringFromBOOL(animated)); if ( ! annotations || ! annotations.count) return; mbgl::LatLngBounds bounds = mbgl::LatLngBounds::empty(); @@ -4815,6 +4905,7 @@ public: - (void)setLocationManager:(nullable id<MGLLocationManager>)locationManager { + MGLLogDebug(@"Setting locationManager: %@", locationManager); if (!locationManager) { locationManager = [[MGLCLLocationManager alloc] init]; } @@ -4877,6 +4968,7 @@ public: - (void)setShowsUserLocation:(BOOL)showsUserLocation { + MGLLogDebug(@"Setting showsUserLocation: %@", MGLStringFromBOOL(showsUserLocation)); if (showsUserLocation == _showsUserLocation || _isTargetingInterfaceBuilder) return; _showsUserLocation = showsUserLocation; @@ -4960,11 +5052,13 @@ public: - (void)setUserTrackingMode:(MGLUserTrackingMode)mode { + MGLLogDebug(@"Setting userTrackingMode: %lu", mode); [self setUserTrackingMode:mode animated:YES]; } - (void)setUserTrackingMode:(MGLUserTrackingMode)mode animated:(BOOL)animated { + MGLLogDebug(@"Setting userTrackingMode: %lu animated: %@", mode, MGLStringFromBOOL(animated)); if (mode == _userTrackingMode) return; if ((mode == MGLUserTrackingModeFollowWithHeading || mode == MGLUserTrackingModeFollowWithCourse) && @@ -5077,6 +5171,7 @@ public: - (void)setShowsUserHeadingIndicator:(BOOL)showsUserHeadingIndicator { + MGLLogDebug(@"Setting showsUserHeadingIndicator: %@", MGLStringFromBOOL(showsUserHeadingIndicator)); _showsUserHeadingIndicator = showsUserHeadingIndicator; if (_showsUserHeadingIndicator) @@ -5442,15 +5537,18 @@ public: - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(CGPoint)point { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@", NSStringFromCGPoint(point)); return [self visibleFeaturesAtPoint:point inStyleLayersWithIdentifiers:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@", NSStringFromCGPoint(point), styleLayerIdentifiers); return [self visibleFeaturesAtPoint:point inStyleLayersWithIdentifiers:styleLayerIdentifiers predicate:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers predicate:(NSPredicate *)predicate { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@ predicate: %@", NSStringFromCGPoint(point), styleLayerIdentifiers, predicate); mbgl::ScreenCoordinate screenCoordinate = { point.x, point.y }; mbgl::optional<std::vector<std::string>> optionalLayerIDs; @@ -5475,14 +5573,17 @@ public: } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(CGRect)rect { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@", NSStringFromCGRect(rect)); return [self visibleFeaturesInRect:rect inStyleLayersWithIdentifiers:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@", NSStringFromCGRect(rect), styleLayerIdentifiers); return [self visibleFeaturesInRect:rect inStyleLayersWithIdentifiers:styleLayerIdentifiers predicate:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers predicate:(NSPredicate *)predicate { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@ predicate: %@", NSStringFromCGRect(rect), styleLayerIdentifiers, predicate); mbgl::ScreenBox screenBox = { { CGRectGetMinX(rect), CGRectGetMinY(rect) }, { CGRectGetMaxX(rect), CGRectGetMaxY(rect) }, @@ -5811,7 +5912,7 @@ public: // Get the annotation tag then use it to get the context. MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation]; - NSAssert(annotationTag != MGLAnnotationTagNotFound, @"-visibleAnnotationsInRect: returned unrecognized annotation"); + MGLAssert(annotationTag != MGLAnnotationTagNotFound, @"-visibleAnnotationsInRect: returned unrecognized annotation"); MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); MGLAnnotationView *annotationView = annotationContext.annotationView; @@ -5851,7 +5952,7 @@ public: } MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation]; - NSAssert(annotationTag != MGLAnnotationTagNotFound, @"-visibleAnnotationsInRect: returned unrecognized annotation"); + MGLAssert(annotationTag != MGLAnnotationTagNotFound, @"-visibleAnnotationsInRect: returned unrecognized annotation"); MGLAnnotationContext &annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); UIView *annotationView = annotationContext.annotationView; @@ -5908,7 +6009,7 @@ public: CGRect positioningRect = annotationView ? annotationView.frame : [self positioningRectForCalloutForAnnotationWithTag:tag]; - NSAssert( ! CGRectIsNull(positioningRect), @"Positioning rect should not be CGRectNull by this point"); + MGLAssert( ! CGRectIsNull(positioningRect), @"Positioning rect should not be CGRectNull by this point"); CGPoint centerPoint = CGPointMake(CGRectGetMidX(positioningRect), CGRectGetMinY(positioningRect)); @@ -6456,6 +6557,7 @@ private: - (void)setAllowsZooming:(BOOL)allowsZooming { + MGLLogDebug(@"Setting allowsZooming: %@", MGLStringFromBOOL(allowsZooming)); self.zoomEnabled = allowsZooming; } @@ -6471,6 +6573,7 @@ private: - (void)setAllowsScrolling:(BOOL)allowsScrolling { + MGLLogDebug(@"Setting allowsScrolling: %@", MGLStringFromBOOL(allowsScrolling)); self.scrollEnabled = allowsScrolling; } @@ -6486,6 +6589,7 @@ private: - (void)setAllowsRotating:(BOOL)allowsRotating { + MGLLogDebug(@"Setting allowsRotating: %@", MGLStringFromBOOL(allowsRotating)); self.rotateEnabled = allowsRotating; } @@ -6501,6 +6605,7 @@ private: - (void)setAllowsTilting:(BOOL)allowsTilting { + MGLLogDebug(@"Setting allowsTilting: %@", MGLStringFromBOOL(allowsTilting)); self.pitchEnabled = allowsTilting; } @@ -6516,6 +6621,7 @@ private: - (void)setShowsHeading:(BOOL)showsHeading { + MGLLogDebug(@"Setting showsHeading: %@", MGLStringFromBOOL(showsHeading)); self.showsUserHeadingIndicator = showsHeading; } diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index a1a5e8c2ab..486870f51c 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -222,23 +222,31 @@ public: - (instancetype)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + MGLLogDebug(@"Initializing frame: %@", NSStringFromRect(frameRect)); [self commonInit]; self.styleURL = nil; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } - (instancetype)initWithFrame:(NSRect)frame styleURL:(nullable NSURL *)styleURL { if (self = [super initWithFrame:frame]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); + MGLLogDebug(@"Initializing frame: %@ styleURL: %@", NSStringFromRect(frame), styleURL); [self commonInit]; self.styleURL = styleURL; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } - (instancetype)initWithCoder:(nonnull NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { + MGLLogInfo(@"Starting %@ initialization.", NSStringFromClass([self class])); [self commonInit]; + MGLLogInfo(@"Finalizing %@ initialization.", NSStringFromClass([self class])); } return self; } @@ -258,7 +266,6 @@ public: } - (void)commonInit { - MGLLogInfo(@"Initializing."); _isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; // Set up cross-platform controllers and resources. @@ -319,7 +326,6 @@ public: _mbglMap->jumpTo(options); _pendingLatitude = NAN; _pendingLongitude = NAN; - MGLLogInfo(@"Initialization completed."); } - (mbgl::Size)size { @@ -633,7 +639,7 @@ public: if (!styleURL) { styleURL = [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion]; } - + MGLLogDebug(@"Setting styleURL: %@", styleURL); // An access token is required to load any default style, including Streets. if (![MGLAccountManager accessToken] && [styleURL.scheme isEqualToString:@"mapbox"]) { NSLog(@"Cannot set the style URL to %@ because no access token has been specified.", styleURL); @@ -646,6 +652,7 @@ public: } - (IBAction)reloadStyle:(__unused id)sender { + MGLLogInfo(@"Reloading style."); NSURL *styleURL = self.styleURL; _mbglMap->getStyle().loadURL(""); self.styleURL = styleURL; @@ -979,10 +986,12 @@ public: } - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate { + MGLLogDebug(@"Setting centerCoordinate: %@", MGLStringFromCLLocationCoordinate2D(centerCoordinate)); [self setCenterCoordinate:centerCoordinate animated:NO]; } - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate animated:(BOOL)animated { + MGLLogDebug(@"Setting centerCoordinate: %@ animated: %@", MGLStringFromCLLocationCoordinate2D(centerCoordinate), MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"centerCoordinate"]; _mbglMap->setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), @@ -1028,10 +1037,12 @@ public: } - (void)setZoomLevel:(double)zoomLevel { + MGLLogDebug(@"Setting zoomLevel: %f", zoomLevel); [self setZoomLevel:zoomLevel animated:NO]; } - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated { + MGLLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"zoomLevel"]; _mbglMap->setZoom(zoomLevel, MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), @@ -1055,11 +1066,13 @@ public: - (void)setMinimumZoomLevel:(double)minimumZoomLevel { + MGLLogDebug(@"Setting minimumZoomLevel: %f", minimumZoomLevel); _mbglMap->setMinZoom(minimumZoomLevel); } - (void)setMaximumZoomLevel:(double)maximumZoomLevel { + MGLLogDebug(@"Setting maximumZoomLevel: %f", maximumZoomLevel); _mbglMap->setMaxZoom(maximumZoomLevel); } @@ -1096,10 +1109,12 @@ public: } - (void)setDirection:(CLLocationDirection)direction { + MGLLogDebug(@"Setting direction: %f", direction); [self setDirection:direction animated:NO]; } - (void)setDirection:(CLLocationDirection)direction animated:(BOOL)animated { + MGLLogDebug(@"Setting direction: %f animated: %@", direction, MGLStringFromBOOL(animated)); [self willChangeValueForKey:@"direction"]; _mbglMap->setBearing(direction, MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets), @@ -1121,14 +1136,17 @@ public: } - (void)setCamera:(MGLMapCamera *)camera { + MGLLogDebug(@"Setting camera: %@", camera); [self setCamera:camera animated:NO]; } - (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated { + MGLLogDebug(@"Setting camera: %@ animated: %@", camera, MGLStringFromBOOL(animated)); [self setCamera:camera withDuration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil completionHandler:NULL]; } - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting camera: %@ duration: %f animationTimingFunction: %@", camera, duration, function); [self setCamera:camera withDuration:duration animationTimingFunction:function edgePadding:self.contentInsets completionHandler:completion]; } @@ -1166,14 +1184,17 @@ public: } - (void)flyToCamera:(MGLMapCamera *)camera completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ completionHandler: %@", camera, completion); [self flyToCamera:camera withDuration:-1 completionHandler:completion]; } - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ withDuration: %f completionHandler: %@", camera, duration, completion); [self flyToCamera:camera withDuration:duration peakAltitude:-1 completionHandler:completion]; } - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion { + MGLLogDebug(@"Setting flyToCamera: %@ withDuration: %f peakAltitude: %f completionHandler: %@", camera, duration, peakAltitude, completion); mbgl::AnimationOptions animationOptions; if (duration >= 0) { animationOptions.duration = MGLDurationFromTimeInterval(duration); @@ -1238,10 +1259,12 @@ public: } - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@", MGLStringFromCoordinateBounds(bounds)); [self setVisibleCoordinateBounds:bounds animated:NO]; } - (void)setVisibleCoordinateBounds:(MGLCoordinateBounds)bounds animated:(BOOL)animated { + MGLLogDebug(@"Setting visibleCoordinateBounds: %@ animated: %@", MGLStringFromCoordinateBounds(bounds), MGLStringFromBOOL(animated)); [self setVisibleCoordinateBounds:bounds edgePadding:NSEdgeInsetsZero animated:animated]; } @@ -2218,6 +2241,7 @@ public: } - (void)setSelectedAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Selecting annotation: %@", annotation); [self willChangeValueForKey:@"selectedAnnotations"]; _selectedAnnotationTag = [self annotationTagForAnnotation:annotation]; if (_selectedAnnotationTag != MGLAnnotationTagNotFound) { @@ -2232,6 +2256,7 @@ public: } - (void)setSelectedAnnotations:(NSArray<id <MGLAnnotation>> *)selectedAnnotations { + MGLLogDebug(@"Selecting: %lu annotations", selectedAnnotations.count); if (!selectedAnnotations.count) { return; } @@ -2252,16 +2277,19 @@ public: - (void)selectAnnotation:(id <MGLAnnotation>)annotation { + MGLLogDebug(@"Selecting annotation: %@", annotation); [self selectAnnotation:annotation atPoint:NSZeroPoint]; } - (void)selectAnnotation:(id <MGLAnnotation>)annotation atPoint:(NSPoint)gesturePoint { + MGLLogDebug(@"Selecting annotation: %@ atPoint: %@", annotation, NSStringFromPoint(gesturePoint)); [self selectAnnotation:annotation atPoint:gesturePoint moveOnscreen:YES animateSelection:YES]; } - (void)selectAnnotation:(id <MGLAnnotation>)annotation atPoint:(NSPoint)gesturePoint moveOnscreen:(BOOL)moveOnscreen animateSelection:(BOOL)animateSelection { + MGLLogDebug(@"Selecting annotation: %@ atPoint: %@ moveOnscreen: %@ animateSelection: %@", annotation, NSStringFromPoint(gesturePoint), MGLStringFromBOOL(moveOnscreen), MGLStringFromBOOL(animateSelection)); id <MGLAnnotation> selectedAnnotation = self.selectedAnnotation; if (annotation == selectedAnnotation) { return; @@ -2373,6 +2401,7 @@ public: } - (void)showAnnotations:(NSArray<id <MGLAnnotation>> *)annotations animated:(BOOL)animated { + MGLLogDebug(@"Showing: %lu annotations animated: %@", annotations.count, MGLStringFromBOOL(animated)); CGFloat maximumPadding = 100; CGFloat yPadding = (NSHeight(self.bounds) / 5 <= maximumPadding) ? (NSHeight(self.bounds) / 5) : maximumPadding; CGFloat xPadding = (NSWidth(self.bounds) / 5 <= maximumPadding) ? (NSWidth(self.bounds) / 5) : maximumPadding; @@ -2598,11 +2627,13 @@ public: } - (void)addOverlay:(id <MGLOverlay>)overlay { + MGLLogDebug(@"Adding overlay: %@", overlay); [self addOverlays:@[overlay]]; } - (void)addOverlays:(NSArray<id <MGLOverlay>> *)overlays { + MGLLogDebug(@"Adding: %lu overlays", overlays.count); #if DEBUG for (id <MGLOverlay> overlay in overlays) { NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"Overlay does not conform to MGLOverlay"); @@ -2612,10 +2643,12 @@ public: } - (void)removeOverlay:(id <MGLOverlay>)overlay { + MGLLogDebug(@"Removing overlay: %@", overlay); [self removeOverlays:@[overlay]]; } - (void)removeOverlays:(NSArray<id <MGLOverlay>> *)overlays { + MGLLogDebug(@"Removing: %lu overlays", overlays.count); #if DEBUG for (id <MGLOverlay> overlay in overlays) { NSAssert([overlay conformsToProtocol:@protocol(MGLOverlay)], @"Overlay does not conform to MGLOverlay"); @@ -2697,14 +2730,17 @@ public: #pragma mark Data - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(NSPoint)point { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@", NSStringFromPoint(point)); return [self visibleFeaturesAtPoint:point inStyleLayersWithIdentifiers:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@", NSStringFromPoint(point), styleLayerIdentifiers); return [self visibleFeaturesAtPoint:point inStyleLayersWithIdentifiers:styleLayerIdentifiers predicate:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesAtPoint:(NSPoint)point inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers predicate:(NSPredicate *)predicate { + MGLLogDebug(@"Querying visibleFeaturesAtPoint: %@ inStyleLayersWithIdentifiers: %@ predicate: %@", NSStringFromPoint(point), styleLayerIdentifiers, predicate); // Cocoa origin is at the lower-left corner. mbgl::ScreenCoordinate screenCoordinate = { point.x, NSHeight(self.bounds) - point.y }; @@ -2728,14 +2764,17 @@ public: } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(NSRect)rect { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@", NSStringFromRect(rect)); return [self visibleFeaturesInRect:rect inStyleLayersWithIdentifiers:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@", NSStringFromRect(rect), styleLayerIdentifiers); return [self visibleFeaturesInRect:rect inStyleLayersWithIdentifiers:styleLayerIdentifiers predicate:nil]; } - (NSArray<id <MGLFeature>> *)visibleFeaturesInRect:(NSRect)rect inStyleLayersWithIdentifiers:(NSSet<NSString *> *)styleLayerIdentifiers predicate:(NSPredicate *)predicate { + MGLLogDebug(@"Querying visibleFeaturesInRect: %@ inStyleLayersWithIdentifiers: %@ predicate: %@", NSStringFromRect(rect), styleLayerIdentifiers, predicate); // Cocoa origin is at the lower-left corner. mbgl::ScreenBox screenBox = { { NSMinX(rect), NSHeight(self.bounds) - NSMaxY(rect) }, |