From 7b09da234af38147640ccd831a16532f2bd8035a Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Tue, 11 Jun 2024 19:01:50 +0200 Subject: [PATCH] Formatting Objective-C and Objective-C++ (#2492) --- .clang-format | 1 + .pre-commit-config.yaml | 2 +- benchmark/ios/iosTestRunner.h | 6 +- .../mbgl/interface/native_apple_interface.h | 4 +- platform/darwin/src/CFHandle.hpp | 9 +- platform/darwin/src/MLNAnnotation.h | 4 +- platform/darwin/src/MLNAttributedExpression.h | 50 +- platform/darwin/src/MLNAttributionInfo.h | 32 +- .../darwin/src/MLNAttributionInfo_Private.h | 9 +- platform/darwin/src/MLNBackendResource.h | 10 +- .../darwin/src/MLNClockDirectionFormatter.h | 6 +- platform/darwin/src/MLNCluster.h | 12 +- .../darwin/src/MLNCompassDirectionFormatter.h | 6 +- platform/darwin/src/MLNComputedShapeSource.h | 45 +- .../src/MLNComputedShapeSource_Private.h | 5 +- platform/darwin/src/MLNConversion.h | 271 ++++---- platform/darwin/src/MLNCoordinateFormatter.h | 6 +- .../darwin/src/MLNCustomDrawableStyleLayer.h | 5 +- .../src/MLNCustomDrawableStyleLayer_Private.h | 6 +- platform/darwin/src/MLNCustomStyleLayer.h | 20 +- .../darwin/src/MLNCustomStyleLayer_Private.h | 6 +- platform/darwin/src/MLNDefaultStyle.h | 4 +- platform/darwin/src/MLNDistanceFormatter.h | 4 +- platform/darwin/src/MLNFeature.h | 41 +- platform/darwin/src/MLNFeature_Private.h | 86 +-- platform/darwin/src/MLNForegroundStyleLayer.h | 3 +- platform/darwin/src/MLNFoundation.h | 2 +- platform/darwin/src/MLNFoundation_Private.h | 21 +- platform/darwin/src/MLNGeometry.h | 222 +++---- platform/darwin/src/MLNGeometry_Private.h | 101 ++- platform/darwin/src/MLNImageSource.h | 43 +- platform/darwin/src/MLNLight_Private.h | 6 +- platform/darwin/src/MLNLocationManager.h | 61 +- .../darwin/src/MLNLocationManager_Private.h | 2 +- platform/darwin/src/MLNLoggingConfiguration.h | 85 +-- .../src/MLNLoggingConfiguration_Private.h | 75 ++- platform/darwin/src/MLNMapCamera.h | 22 +- platform/darwin/src/MLNMapSnapshotter.h | 85 +-- platform/darwin/src/MLNMultiPoint.h | 25 +- platform/darwin/src/MLNMultiPoint_Private.h | 2 +- platform/darwin/src/MLNNetworkConfiguration.h | 7 +- .../src/MLNNetworkConfiguration_Private.h | 9 +- platform/darwin/src/MLNOfflinePack.h | 161 ++--- platform/darwin/src/MLNOfflineRegion.h | 6 +- platform/darwin/src/MLNOfflineStorage.h | 151 +++-- .../darwin/src/MLNOfflineStorage_Private.h | 5 +- platform/darwin/src/MLNOverlay.h | 4 +- platform/darwin/src/MLNPointAnnotation.h | 4 +- platform/darwin/src/MLNPointCollection.h | 5 +- platform/darwin/src/MLNPolygon.h | 11 +- platform/darwin/src/MLNPolyline.h | 11 +- platform/darwin/src/MLNPolyline_Private.h | 1 - platform/darwin/src/MLNRasterDEMSource.h | 10 +- platform/darwin/src/MLNRasterTileSource.h | 19 +- .../darwin/src/MLNRasterTileSource_Private.h | 15 +- platform/darwin/src/MLNReachability.h | 59 +- .../darwin/src/MLNRendererConfiguration.h | 17 +- platform/darwin/src/MLNRendererFrontend.h | 114 ++-- platform/darwin/src/MLNSettings.h | 26 +- platform/darwin/src/MLNSettings_Private.h | 4 +- platform/darwin/src/MLNShape.h | 11 +- platform/darwin/src/MLNShapeOfflineRegion.h | 15 +- .../src/MLNShapeOfflineRegion_Private.h | 3 +- platform/darwin/src/MLNShapeSource.h | 121 ++-- platform/darwin/src/MLNShapeSource_Private.h | 13 +- platform/darwin/src/MLNShape_Private.h | 2 +- platform/darwin/src/MLNSource_Private.h | 36 +- platform/darwin/src/MLNStyle.h | 24 +- platform/darwin/src/MLNStyleLayer.h | 13 +- platform/darwin/src/MLNStyleLayerManager.h | 4 +- platform/darwin/src/MLNStyleLayer_Private.h | 48 +- platform/darwin/src/MLNStyleValue.h | 39 +- platform/darwin/src/MLNStyleValue_Private.h | 588 +++++++++--------- platform/darwin/src/MLNStyle_Private.h | 22 +- .../darwin/src/MLNTilePyramidOfflineRegion.h | 19 +- .../src/MLNTilePyramidOfflineRegion_Private.h | 3 +- platform/darwin/src/MLNTileServerOptions.h | 138 ++-- platform/darwin/src/MLNTileSource.h | 51 +- platform/darwin/src/MLNTileSource_Private.h | 9 +- platform/darwin/src/MLNTypes.h | 141 ++--- platform/darwin/src/MLNValueEvaluator.h | 50 +- platform/darwin/src/MLNVectorStyleLayer.h | 8 +- platform/darwin/src/MLNVectorTileSource.h | 28 +- .../darwin/src/MLNVectorTileSource_Private.h | 3 +- platform/darwin/src/NSArray+MLNAdditions.h | 5 +- platform/darwin/src/NSBundle+MLNAdditions.h | 6 +- platform/darwin/src/NSCoder+MLNAdditions.h | 5 +- platform/darwin/src/NSDate+MLNAdditions.h | 3 +- .../darwin/src/NSException+MLNAdditions.h | 5 +- .../darwin/src/NSExpression+MLNAdditions.h | 112 ++-- .../src/NSExpression+MLNPrivateAdditions.h | 12 +- .../darwin/src/NSPredicate+MLNAdditions.h | 8 +- platform/darwin/src/NSValue+MLNAdditions.h | 8 +- platform/darwin/src/async_task.cpp | 19 +- platform/darwin/src/gl_functions.cpp | 532 ++++++++-------- platform/darwin/src/run_loop.cpp | 2 +- platform/darwin/src/timer.cpp | 15 +- platform/darwin/test/MLNStyleLayerTests.h | 3 +- platform/darwin/test/MLNTestUtility.h | 21 +- platform/darwin/test/test-Bridging-Header.h | 1 - .../Integration_Test_Harness/AppDelegate.h | 1 - .../MLNIntegrationTestCase.h | 33 +- .../MLNMapViewIntegrationTest.h | 12 +- .../MLNTestLocationManager.h | 6 +- .../integration-Bridging-Header.h | 1 - platform/ios/app/MBXStateManager.h | 4 +- .../ios/benchmark/MBXBenchViewController.h | 2 +- platform/ios/benchmark/locations.cpp | 34 +- platform/ios/benchmark/locations.hpp | 6 +- platform/ios/src/MLNAnnotationContainerView.h | 3 +- platform/ios/src/MLNAnnotationImage.h | 7 +- platform/ios/src/MLNAnnotationView.h | 74 +-- platform/ios/src/MLNAnnotationView_Private.h | 2 +- platform/ios/src/MLNCalloutView.h | 32 +- platform/ios/src/MLNCameraChangeReason.h | 56 +- platform/ios/src/MLNCompactCalloutView.h | 2 +- platform/ios/src/MLNCompassButton.h | 3 +- platform/ios/src/MLNMapAccessibilityElement.h | 9 +- platform/ios/src/MLNMapProjection.h | 6 +- platform/ios/src/MLNMapView+IBAdditions.h | 2 +- platform/ios/src/MLNMapView+Impl.h | 106 ++-- platform/ios/src/MLNMapView+Metal.h | 66 +- platform/ios/src/MLNMapView+OpenGL.h | 72 +-- platform/ios/src/MLNMapView.h | 416 ++++++++----- platform/ios/src/MLNMapViewDelegate.h | 87 ++- platform/ios/src/MLNMapView_Private.h | 18 +- platform/ios/src/MLNScaleBar.h | 2 +- platform/ios/src/MLNUserLocation.h | 6 +- .../ios/src/MLNUserLocationAnnotationView.h | 6 +- .../MLNUserLocationAnnotationView_Private.h | 2 +- .../src/MLNUserLocationHeadingArrowLayer.h | 3 +- .../ios/src/MLNUserLocationHeadingBeamLayer.h | 3 +- .../ios/src/MLNUserLocationHeadingIndicator.h | 3 +- platform/ios/src/Mapbox.h | 10 +- platform/ios/src/UIColor+MLNAdditions.h | 2 +- platform/ios/src/UIImage+MLNAdditions.h | 5 +- platform/ios/test/MLNMockGestureRecognizers.h | 10 +- platform/ios/test/common/AppDelegate.h | 2 +- platform/ios/test/core/iosTestRunner.h | 6 +- platform/ios/test/core/ios_test_runner.cpp | 10 +- platform/macos/app/AppDelegate.h | 2 +- platform/macos/src/MLNAnnotationImage.h | 3 +- platform/macos/src/MLNMapView+Impl.h | 58 +- platform/macos/src/MLNMapView+Metal.h | 52 +- platform/macos/src/MLNMapView.h | 213 ++++--- platform/macos/src/MLNMapViewDelegate.h | 50 +- platform/macos/src/MLNMapView_Private.h | 6 +- platform/macos/src/Mapbox.h | 62 +- platform/macos/src/NSColor+MLNAdditions.h | 2 +- platform/macos/src/NSImage+MLNAdditions.h | 4 +- platform/scripts/check-public-symbols.js | 4 +- render-test/ios/iosTestRunner.h | 10 +- render-test/ios/ios_test_runner.cpp | 7 +- 153 files changed, 3099 insertions(+), 2694 deletions(-) diff --git a/.clang-format b/.clang-format index 8a61bdedb..36240a832 100644 --- a/.clang-format +++ b/.clang-format @@ -19,4 +19,5 @@ Language: Cpp --- Language: ObjC BasedOnStyle: Google +ObjCSpaceAfterProperty: true ... diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f83cf2e5..bc5bc2dd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: hooks: - id: clang-format files: '.*\.(hpp|cpp|h)' - exclude: '(vendor/.*|platform/(ios|darwin|macos)/.*|test/ios/.*|render-test/ios/.*|benchmark/ios/.*)' + exclude: '(vendor/.*|darwin/include/mbgl/storage/reachability.h)' - repo: https://github.com/keith/pre-commit-buildifier rev: 6.4.0 hooks: diff --git a/benchmark/ios/iosTestRunner.h b/benchmark/ios/iosTestRunner.h index d8cd7991b..f89e5bafb 100644 --- a/benchmark/ios/iosTestRunner.h +++ b/benchmark/ios/iosTestRunner.h @@ -3,10 +3,10 @@ NSString *dataDir = @"benchmark-data"; NSString *resultFilePath = @"benchmark/results.json"; -__attribute__((visibility ("default"))) +__attribute__((visibility("default"))) @interface IosTestRunner : NSObject -- (NSString*) getResultPath; -- (BOOL) getTestStatus; +- (NSString *)getResultPath; +- (BOOL)getTestStatus; @end diff --git a/platform/darwin/include/mbgl/interface/native_apple_interface.h b/platform/darwin/include/mbgl/interface/native_apple_interface.h index 1a6eba8db..7633819bb 100644 --- a/platform/darwin/include/mbgl/interface/native_apple_interface.h +++ b/platform/darwin/include/mbgl/interface/native_apple_interface.h @@ -26,9 +26,9 @@ NS_ASSUME_NONNULL_BEGIN @end -#define MLN_APPLE_EXPORT __attribute__((visibility ("default"))) +#define MLN_APPLE_EXPORT __attribute__((visibility("default"))) -@interface MLNNativeNetworkManager: NSObject +@interface MLNNativeNetworkManager : NSObject + (MLNNativeNetworkManager *)sharedManager; diff --git a/platform/darwin/src/CFHandle.hpp b/platform/darwin/src/CFHandle.hpp index edcc9aafd..23beecb6a 100644 --- a/platform/darwin/src/CFHandle.hpp +++ b/platform/darwin/src/CFHandle.hpp @@ -6,10 +6,10 @@ or just use unique_ptr with a custom deleter. CFHandle has no special treatment for null handles -- be careful not to let it hold a null handle if the behavior of the Releaser isn't defined for null. - + ex: using CFDataHandle = CFHandle; - + CFDataHandle data(CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, reinterpret_cast(source.data()), source.size(), kCFAllocatorNull)); @@ -19,13 +19,14 @@ namespace { template struct CFHandle { - CFHandle(HandleType handle_): handle(handle_) {} + CFHandle(HandleType handle_) + : handle(handle_) {} ~CFHandle() { Releaser(handle); } HandleType operator*() { return handle; } operator bool() { return handle; } + private: HandleType handle; }; } // namespace - diff --git a/platform/darwin/src/MLNAnnotation.h b/platform/darwin/src/MLNAnnotation.h index af1256551..62568f4ea 100644 --- a/platform/darwin/src/MLNAnnotation.h +++ b/platform/darwin/src/MLNAnnotation.h @@ -1,5 +1,5 @@ -#import #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN An object that adopts this protocol must implement the `coordinate` property. The other methods of this protocol are optional. - + #### Related examples TODO: Annotation models TODO: Annotation views, learn how to add objects that follow the diff --git a/platform/darwin/src/MLNAttributedExpression.h b/platform/darwin/src/MLNAttributedExpression.h index a5e7d9888..1250ae8a6 100644 --- a/platform/darwin/src/MLNAttributedExpression.h +++ b/platform/darwin/src/MLNAttributedExpression.h @@ -3,12 +3,13 @@ NS_ASSUME_NONNULL_BEGIN /** Options for `MLNAttributedExpression.attributes`. */ -typedef NSString * MLNAttributedExpressionKey NS_TYPED_ENUM; +typedef NSString *MLNAttributedExpressionKey NS_TYPED_ENUM; /** The font name string array expression used to format the text. */ FOUNDATION_EXTERN MLN_EXPORT MLNAttributedExpressionKey const MLNFontNamesAttribute; -/** The font scale number expression relative to `MLNSymbolStyleLayer.textFontSize` used to format the text. */ +/** The font scale number expression relative to `MLNSymbolStyleLayer.textFontSize` used to format + * the text. */ FOUNDATION_EXTERN MLN_EXPORT MLNAttributedExpressionKey const MLNFontScaleAttribute; /** The font color expression used to format the text. */ @@ -17,18 +18,18 @@ FOUNDATION_EXTERN MLN_EXPORT MLNAttributedExpressionKey const MLNFontColorAttrib /** An `MLNAttributedExpression` object associates text formatting attibutes (such as font size or font names) to an `NSExpression`. - + ### Example ```swift let redColor = UIColor.red let expression = NSExpression(forConstantValue: "Foo") - let attributes: [MLNAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : NSExpression(forConstantValue: ["DIN Offc Pro Italic", - "Arial Unicode MS Regular"]), - .fontScaleAttribute: NSExpression(forConstantValue: 1.2), - .fontColorAttribute: NSExpression(forConstantValue: redColor)] + let attributes: [MLNAttributedExpressionKey: NSExpression] = [.fontNamesAttribute : + NSExpression(forConstantValue: ["DIN Offc Pro Italic", "Arial Unicode MS Regular"]), + .fontScaleAttribute: + NSExpression(forConstantValue: 1.2), .fontColorAttribute: NSExpression(forConstantValue: redColor)] let attributedExpression = MLNAttributedExpression(expression, attributes:attributes) ``` - + */ MLN_EXPORT @interface MLNAttributedExpression : NSObject @@ -48,7 +49,8 @@ MLN_EXPORT `MLNFontColorAttribute` | An `NSExpression` evaluating to an `UIColor`. */ -@property (strong, nonatomic, readonly) NSDictionary *attributes; +@property (strong, nonatomic, readonly) + NSDictionary *attributes; #else /** The formatting attributes dictionary. @@ -58,29 +60,39 @@ MLN_EXPORT `MLNFontScaleAttribute` | An `NSExpression` evaluating to an `NSNumber` value. `MLNFontColorAttribute` | An `NSExpression` evaluating to an `NSColor` on macos. */ -@property (strong, nonatomic, readonly) NSDictionary *attributes; +@property (strong, nonatomic, readonly) + NSDictionary *attributes; #endif - /** - Returns an `MLNAttributedExpression` object initialized with an expression and no attribute information. + Returns an `MLNAttributedExpression` object initialized with an expression and no attribute + information. */ - (instancetype)initWithExpression:(NSExpression *)expression; -/** - Returns an `MLNAttributedExpression` object initialized with an expression and text format attributes. +/** + Returns an `MLNAttributedExpression` object initialized with an expression and text format + attributes. */ -- (instancetype)initWithExpression:(NSExpression *)expression attributes:(nonnull NSDictionary *)attrs; +- (instancetype) + initWithExpression:(NSExpression *)expression + attributes:(nonnull NSDictionary *)attrs; /** - Creates an `MLNAttributedExpression` object initialized with an expression and the format attributes for font names and font size. + Creates an `MLNAttributedExpression` object initialized with an expression and the format + attributes for font names and font size. */ -+ (instancetype)attributedExpression:(NSExpression *)expression fontNames:(nullable NSArray *)fontNames fontScale:(nullable NSNumber *)fontScale; ++ (instancetype)attributedExpression:(NSExpression *)expression + fontNames:(nullable NSArray *)fontNames + fontScale:(nullable NSNumber *)fontScale; /** - Creates an `MLNAttributedExpression` object initialized with an expression and the format attributes dictionary. + Creates an `MLNAttributedExpression` object initialized with an expression and the format + attributes dictionary. */ -+ (instancetype)attributedExpression:(NSExpression *)expression attributes:(nonnull NSDictionary *)attrs; ++ (instancetype) + attributedExpression:(NSExpression *)expression + attributes:(nonnull NSDictionary *)attrs; @end diff --git a/platform/darwin/src/MLNAttributionInfo.h b/platform/darwin/src/MLNAttributionInfo.h index 14264d059..94107384c 100644 --- a/platform/darwin/src/MLNAttributionInfo.h +++ b/platform/darwin/src/MLNAttributionInfo.h @@ -1,6 +1,6 @@ -#import #import #import +#import #import "MLNFoundation.h" #import "MLNTypes.h" @@ -11,18 +11,18 @@ NS_ASSUME_NONNULL_BEGIN The attribution info is represented in the longest format available. */ typedef NS_ENUM(NSUInteger, MLNAttributionInfoStyle) { - /** - Specifies a short attribution info style. - */ - MLNAttributionInfoStyleShort = 1, - /** - Specifies a medium attribution info style. - */ - MLNAttributionInfoStyleMedium, - /** - Specifies a long attribution info style. - */ - MLNAttributionInfoStyleLong + /** + Specifies a short attribution info style. + */ + MLNAttributionInfoStyleShort = 1, + /** + Specifies a medium attribution info style. + */ + MLNAttributionInfoStyleMedium, + /** + Specifies a long attribution info style. + */ + MLNAttributionInfoStyleLong }; /** @@ -66,12 +66,12 @@ MLN_EXPORT /** Returns a copy of the current `title` formatted accordingly to `style`. - + Example: If the `style` property is set to `MLNAttributionInfoStyleShort` and the `title` property is set to `OpenStreetMap`, then this method returns `OSM`. - + @param style The attribution info style. - + @return The `NSAttributedString` styled title. */ - (NSAttributedString *)titleWithStyle:(MLNAttributionInfoStyle)style; diff --git a/platform/darwin/src/MLNAttributionInfo_Private.h b/platform/darwin/src/MLNAttributionInfo_Private.h index e2326b4fa..7fd7f2ff9 100644 --- a/platform/darwin/src/MLNAttributionInfo_Private.h +++ b/platform/darwin/src/MLNAttributionInfo_Private.h @@ -1,6 +1,6 @@ -#import #import #import +#import #import "MLNAttributionInfo.h" @@ -16,9 +16,12 @@ NS_ASSUME_NONNULL_BEGIN @param fontSize The default text size in points. @param linkColor The default link color. */ -+ (NSArray *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MLNColor *)linkColor; ++ (NSArray *)attributionInfosFromHTMLString:(nullable NSString *)htmlString + fontSize:(CGFloat)fontSize + linkColor:(nullable MLNColor *)linkColor; -+ (NSAttributedString *)attributedStringForAttributionInfos:(NSArray *)attributionInfos; ++ (NSAttributedString *)attributedStringForAttributionInfos: + (NSArray *)attributionInfos; @end diff --git a/platform/darwin/src/MLNBackendResource.h b/platform/darwin/src/MLNBackendResource.h index 97f9c9f63..e8af9ae63 100644 --- a/platform/darwin/src/MLNBackendResource.h +++ b/platform/darwin/src/MLNBackendResource.h @@ -2,18 +2,16 @@ #import -typedef struct -{ +typedef struct { MTKView *mtkView; - id device; + id device; MTLRenderPassDescriptor *renderPassDescriptor; - id commandBuffer; + id commandBuffer; } MLNBackendResource; #else -typedef struct -{ +typedef struct { } MLNBackendResource; #endif diff --git a/platform/darwin/src/MLNClockDirectionFormatter.h b/platform/darwin/src/MLNClockDirectionFormatter.h index 53edd0bf6..ce30a7be5 100644 --- a/platform/darwin/src/MLNClockDirectionFormatter.h +++ b/platform/darwin/src/MLNClockDirectionFormatter.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" @@ -39,7 +39,9 @@ MLN_EXPORT /** This method is not supported for the `MLNDirectionFormatter` class. */ -- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error; +- (BOOL)getObjectValue:(out id __nullable *__nullable)obj + forString:(NSString *)string + errorDescription:(out NSString *__nullable *__nullable)error; @end diff --git a/platform/darwin/src/MLNCluster.h b/platform/darwin/src/MLNCluster.h index f59ce577a..93a1ffd42 100644 --- a/platform/darwin/src/MLNCluster.h +++ b/platform/darwin/src/MLNCluster.h @@ -13,25 +13,25 @@ FOUNDATION_EXTERN MLN_EXPORT const NSUInteger MLNClusterIdentifierInvalid; /** A protocol that feature subclasses (i.e. those already conforming to the `MLNFeature` protocol) conform to if they represent clusters. - + Currently the only class that conforms to `MLNCluster` is `MLNPointFeatureCluster` (a subclass of `MLNPointFeature`). - + To check if a feature is a cluster, check conformity to `MLNCluster`, for example: - + ```swift let shape = try! MLNShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue) - + guard let pointFeature = shape as? MLNPointFeature else { throw ExampleError.unexpectedFeatureType } - + // Check for cluster conformance guard let cluster = pointFeature as? MLNCluster else { throw ExampleError.featureIsNotACluster } - + // Currently the only supported class that conforms to `MLNCluster` is // `MLNPointFeatureCluster` guard cluster is MLNPointFeatureCluster else { diff --git a/platform/darwin/src/MLNCompassDirectionFormatter.h b/platform/darwin/src/MLNCompassDirectionFormatter.h index f428ae547..a76ca9e44 100644 --- a/platform/darwin/src/MLNCompassDirectionFormatter.h +++ b/platform/darwin/src/MLNCompassDirectionFormatter.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" @@ -36,7 +36,9 @@ MLN_EXPORT /** This method is not supported for the `MLNDirectionFormatter` class. */ -- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error; +- (BOOL)getObjectValue:(out id __nullable *__nullable)obj + forString:(NSString *)string + errorDescription:(out NSString *__nullable *__nullable)error; @end diff --git a/platform/darwin/src/MLNComputedShapeSource.h b/platform/darwin/src/MLNComputedShapeSource.h index c0ff97c34..2703ff4ff 100644 --- a/platform/darwin/src/MLNComputedShapeSource.h +++ b/platform/darwin/src/MLNComputedShapeSource.h @@ -1,7 +1,7 @@ #import "MLNFoundation.h" #import "MLNGeometry.h" -#import "MLNTypes.h" #import "MLNShapeSource.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -11,9 +11,9 @@ NS_ASSUME_NONNULL_BEGIN An `NSNumber` object containing a Boolean value; specifies whether the shape of an `MLNComputedShapeSource` should be wrapped to accomodate coordinates with longitudes beyond −180 and 180. The default value is `NO`. - + Setting this option to `YES` affects rendering performance. - + This option is used with the `MLNComputedShapeSource` class; it is ignored when creating an `MLNShapeSource` object. */ @@ -23,10 +23,10 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionWrap An `NSNumber` object containing a Boolean value; specifies whether the shape of an `MLNComputedShapeSource` should be clipped at the edge of each tile. The default value is `NO`. - + Setting this option to `YES` affects rendering performance. Use this option to clip `MLNPolyline`s and `MLNPolygon`s at tile boundaries without artifacts. - + This option is used with the `MLNComputedShapeSource` class; it is ignored when creating an `MLNShapeSource` object. */ @@ -50,7 +50,9 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNInvalidDatasourceExceptio @param y Tile Y coordinate. @param zoomLevel Tile zoom level. */ -- (NSArray *>*)featuresInTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel; +- (NSArray *> *)featuresInTileAtX:(NSUInteger)x + y:(NSUInteger)y + zoomLevel:(NSUInteger)zoomLevel; /** Fetch features for a tile. This method will not be invoked on the main queue, it @@ -58,7 +60,8 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNInvalidDatasourceExceptio @param bounds The bounds to fetch data for. @param zoomLevel Tile zoom level. */ -- (NSArray *>*)featuresInCoordinateBounds:(MLNCoordinateBounds)bounds zoomLevel:(NSUInteger)zoomLevel; +- (NSArray *> *)featuresInCoordinateBounds:(MLNCoordinateBounds)bounds + zoomLevel:(NSUInteger)zoomLevel; @end @@ -70,14 +73,14 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNInvalidDatasourceExceptio `MLNStyle` object along with an `MLNVectorStyleLayer` object. The vector style layer defines the appearance of any content supplied by the computed shape source. - + `MLNComputedShapeSource` is similar to `MLNShapeSource` but is optimized for data sets that change dynamically or are too large to fit completely in memory. It is also useful for data that is divided into tiles in a format other than Mapbox Vector Tiles. For GeoJSON data, use the `MLNShapeSource` class. For static tiles or Mapbox Vector Tiles, use the `MLNVectorTileSource` class. - + You can add and remove sources dynamically using methods such as `-[MLNStyle addSource:]` and `-[MLNStyle sourceWithIdentifier:]`. This class cannot be represented in a style JSON file; you must add it ot the style at @@ -91,7 +94,7 @@ MLN_EXPORT dictionary of options for the source according to the style specification. - + This class supports the following options: `MLNShapeSourceOptionMinimumZoomLevel`, `MLNShapeSourceOptionMaximumZoomLevel`, `MLNShapeSourceOptionBuffer`, @@ -103,14 +106,16 @@ MLN_EXPORT @param identifier A string that uniquely identifies the source. @param options An `NSDictionary` of options for this source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier options:(nullable NSDictionary *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + options:(nullable NSDictionary *)options + NS_DESIGNATED_INITIALIZER; /** Returns a custom shape data source initialized with an identifier, data source, and a dictionary of options for the source according to the style specification. - + This class supports the following options: `MLNShapeSourceOptionMinimumZoomLevel`, `MLNShapeSourceOptionMaximumZoomLevel`, `MLNShapeSourceOptionBuffer`, @@ -122,7 +127,9 @@ MLN_EXPORT @param identifier A string that uniquely identifies the source. @param options An `NSDictionary` of options for this source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier dataSource:(id)dataSource options:(nullable NSDictionary *)options; +- (instancetype)initWithIdentifier:(NSString *)identifier + dataSource:(id)dataSource + options:(nullable NSDictionary *)options; /** Invalidates all the features and properties intersecting with or contained in @@ -130,7 +137,7 @@ MLN_EXPORT `MLNComputedShapeSourceDataSource`. @param bounds Coordinate bounds to invalidate. */ -- (void) invalidateBounds:(MLNCoordinateBounds)bounds; +- (void)invalidateBounds:(MLNCoordinateBounds)bounds; /** Invalidates all the feautres and properties of a given tile. A new fetch request @@ -139,7 +146,7 @@ MLN_EXPORT @param y Tile Y coordinate. @param zoomLevel Tile zoom level. */ -- (void) invalidateTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel; +- (void)invalidateTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel; /** Set a new set of features for a tile. This method can be invkoed from background threads. @@ -150,10 +157,14 @@ MLN_EXPORT @param y Tile Y coordinate. @param zoomLevel Tile zoom level. */ -- (void) setFeatures:(NSArray *>*)features inTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel; +- (void)setFeatures:(NSArray *> *)features + inTileAtX:(NSUInteger)x + y:(NSUInteger)y + zoomLevel:(NSUInteger)zoomLevel; /** - An object that implements the `MLNComputedShapeSourceDataSource` protocol that will be queried for tile data. + An object that implements the `MLNComputedShapeSourceDataSource` protocol that will be queried for + tile data. */ @property (nonatomic, weak, nullable) id dataSource; diff --git a/platform/darwin/src/MLNComputedShapeSource_Private.h b/platform/darwin/src/MLNComputedShapeSource_Private.h index 3dee67c9e..704bce50f 100644 --- a/platform/darwin/src/MLNComputedShapeSource_Private.h +++ b/platform/darwin/src/MLNComputedShapeSource_Private.h @@ -1,12 +1,13 @@ +#import "MLNComputedShapeSource.h" #import "MLNFoundation.h" #import "MLNTypes.h" -#import "MLNComputedShapeSource.h" #include NS_ASSUME_NONNULL_BEGIN MLN_EXPORT -mbgl::style::CustomGeometrySource::Options MBGLCustomGeometrySourceOptionsFromDictionary(NSDictionary *options); +mbgl::style::CustomGeometrySource::Options MBGLCustomGeometrySourceOptionsFromDictionary( + NSDictionary *options); NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MLNConversion.h b/platform/darwin/src/MLNConversion.h index 3acdf8a7b..5d7cf2ed0 100644 --- a/platform/darwin/src/MLNConversion.h +++ b/platform/darwin/src/MLNConversion.h @@ -8,164 +8,165 @@ namespace conversion { // A wrapper class for `id`, so as not to confuse ARC. class Holder { -public: - Holder(const id v) : value(v) {} - const id value; + public: + Holder(const id v) : value(v) {} + const id value; }; template <> class ConversionTraits { -public: - static bool isUndefined(const Holder& holder) { - const id value = holder.value; - return !value || value == [NSNull null]; - } + public: + static bool isUndefined(const Holder& holder) { + const id value = holder.value; + return !value || value == [NSNull null]; + } - static bool isArray(const Holder& holder) { - const id value = holder.value; - return [value isKindOfClass:[NSArray class]]; - } + static bool isArray(const Holder& holder) { + const id value = holder.value; + return [value isKindOfClass:[NSArray class]]; + } - static bool isObject(const Holder& holder) { - const id value = holder.value; - return [value isKindOfClass:[NSDictionary class]]; - } + static bool isObject(const Holder& holder) { + const id value = holder.value; + return [value isKindOfClass:[NSDictionary class]]; + } - static std::size_t arrayLength(const Holder& holder) { - const id value = holder.value; - NSCAssert([value isKindOfClass:[NSArray class]], @"Value must be an NSArray for getLength()."); - NSArray *array = value; - auto length = [array count]; - NSCAssert(length <= std::numeric_limits::max(), @"Array length out of bounds."); - return length; - } + static std::size_t arrayLength(const Holder& holder) { + const id value = holder.value; + NSCAssert([value isKindOfClass:[NSArray class]], @"Value must be an NSArray for getLength()."); + NSArray* array = value; + auto length = [array count]; + NSCAssert(length <= std::numeric_limits::max(), @"Array length out of bounds."); + return length; + } - static Holder arrayMember(const Holder& holder, std::size_t i) { - const id value = holder.value; - NSCAssert([value isKindOfClass:[NSArray class]], @"Value must be an NSArray for get(int)."); - NSCAssert(i < NSUIntegerMax, @"Index must be less than NSUIntegerMax"); - return {[value objectAtIndex: i]}; - } + static Holder arrayMember(const Holder& holder, std::size_t i) { + const id value = holder.value; + NSCAssert([value isKindOfClass:[NSArray class]], @"Value must be an NSArray for get(int)."); + NSCAssert(i < NSUIntegerMax, @"Index must be less than NSUIntegerMax"); + return {[value objectAtIndex:i]}; + } - static std::optional objectMember(const Holder& holder, const char *key) { - const id value = holder.value; - NSCAssert([value isKindOfClass:[NSDictionary class]], @"Value must be an NSDictionary for get(string)."); - NSObject *member = [value objectForKey: @(key)]; - if (member && member != [NSNull null]) { - return {member}; - } else { - return {}; - } + static std::optional objectMember(const Holder& holder, const char* key) { + const id value = holder.value; + NSCAssert([value isKindOfClass:[NSDictionary class]], + @"Value must be an NSDictionary for get(string)."); + NSObject* member = [value objectForKey:@(key)]; + if (member && member != [NSNull null]) { + return {member}; + } else { + return {}; } + } // Compiler is wrong about `Fn` parameter missing a nullability specifier. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnullability-completeness" - template - static std::optional eachMember(const Holder& holder, Fn&& visit) { + template + static std::optional eachMember(const Holder& holder, Fn&& visit) { #pragma clang diagnostic pop - [holder.value enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { - auto result = visit(std::string(static_cast([key UTF8String])), obj); - if (result) { - *stop = YES; - } + [holder.value + enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL* _Nonnull stop) { + auto result = visit(std::string(static_cast([key UTF8String])), obj); + if (result) { + *stop = YES; + } }]; + return {}; + } + + static std::optional toBool(const Holder& holder) { + const id value = holder.value; + if (_isBool(value)) { + return ((NSNumber*)value).boolValue; + } else { + return {}; + } + } + + static std::optional toNumber(const Holder& holder) { + const id value = holder.value; + if (_isNumber(value)) { + return ((NSNumber*)value).floatValue; + } else { + return {}; + } + } + + static std::optional toDouble(const Holder& holder) { + const id value = holder.value; + if (_isNumber(value)) { + return ((NSNumber*)value).doubleValue; + } else { + return {}; + } + } + + static std::optional toString(const Holder& holder) { + const id value = holder.value; + if (_isString(value)) { + return std::string(static_cast([value UTF8String])); + } else { + return {}; + } + } + + static std::optional toValue(const Holder& holder) { + const id value = holder.value; + if (isUndefined(value)) { + return {}; + } else if (_isBool(value)) { + return {*toBool(holder)}; + } else if (_isString(value)) { + return {*toString(holder)}; + } else if (_isNumber(value)) { + return {*toDouble(holder)}; + } else { + return {}; + } + } + + static std::optional toGeoJSON(const Holder& holder, Error& error) { + id object = holder.value; + if ([object isKindOfClass:[NSDictionary class]]) { + NSError* serializationError; + NSData* data = [NSJSONSerialization dataWithJSONObject:object + options:0 + error:&serializationError]; + if (serializationError) { + error = {std::string(serializationError.localizedDescription.UTF8String)}; return {}; + } + NSString* string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + return mapbox::geojson::parse(string.UTF8String); + } else { + error = {std::string( + [NSString stringWithFormat:@"%@ is not a GeoJSON object.", object].UTF8String)}; + return {}; } + } - static std::optional toBool(const Holder& holder) { - const id value = holder.value; - if (_isBool(value)) { - return ((NSNumber *)value).boolValue; - } else { - return {}; - } - } + private: + static bool _isBool(const id value) { + if (![value isKindOfClass:[NSNumber class]]) return false; + // char: 32-bit boolean + // BOOL: 64-bit boolean + NSNumber* number = value; + return ((strcmp([number objCType], @encode(char)) == 0) || + (strcmp([number objCType], @encode(BOOL)) == 0)); + } - static std::optional toNumber(const Holder& holder) { - const id value = holder.value; - if (_isNumber(value)) { - return ((NSNumber *)value).floatValue; - } else { - return {}; - } - } + static bool _isNumber(const id value) { + return [value isKindOfClass:[NSNumber class]] && !_isBool(value); + } - static std::optional toDouble(const Holder& holder) { - const id value = holder.value; - if (_isNumber(value)) { - return ((NSNumber *)value).doubleValue; - } else { - return {}; - } - } - - static std::optional toString(const Holder& holder) { - const id value = holder.value; - if (_isString(value)) { - return std::string(static_cast([value UTF8String])); - } else { - return {}; - } - } - - static std::optional toValue(const Holder& holder) { - const id value = holder.value; - if (isUndefined(value)) { - return {}; - } else if (_isBool(value)) { - return { *toBool(holder) }; - } else if ( _isString(value)) { - return { *toString(holder) }; - } else if (_isNumber(value)) { - return { *toDouble(holder) }; - } else { - return {}; - } - } - - static std::optional toGeoJSON(const Holder& holder, Error& error) { - id object = holder.value; - if ([object isKindOfClass:[NSDictionary class]]) { - NSError *serializationError; - NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:&serializationError]; - if (serializationError) { - error = { std::string(serializationError.localizedDescription.UTF8String) }; - return {}; - } - NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - return mapbox::geojson::parse(string.UTF8String); - } else { - error = { std::string([NSString stringWithFormat:@"%@ is not a GeoJSON object.", object].UTF8String) }; - return {}; - } - } - -private: - static bool _isBool(const id value) { - if (![value isKindOfClass:[NSNumber class]]) return false; - // char: 32-bit boolean - // BOOL: 64-bit boolean - NSNumber *number = value; - return ((strcmp([number objCType], @encode(char)) == 0) || - (strcmp([number objCType], @encode(BOOL)) == 0)); - } - - static bool _isNumber(const id value) { - return [value isKindOfClass:[NSNumber class]] && !_isBool(value); - } - - static bool _isString(const id value) { - return [value isKindOfClass:[NSString class]]; - } + static bool _isString(const id value) { return [value isKindOfClass:[NSString class]]; } }; -inline Convertible makeConvertible(const id value) { - return Convertible(Holder(value)); -} +inline Convertible makeConvertible(const id value) { return Convertible(Holder(value)); } -} // namespace conversion -} // namespace style -} // namespace mbgl +} // namespace conversion +} // namespace style +} // namespace mbgl NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MLNCoordinateFormatter.h b/platform/darwin/src/MLNCoordinateFormatter.h index f534305ef..bc5ab24ee 100644 --- a/platform/darwin/src/MLNCoordinateFormatter.h +++ b/platform/darwin/src/MLNCoordinateFormatter.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" @@ -49,7 +49,9 @@ MLN_EXPORT /** This method is not supported for the `MLNCoordinateFormatter` class. */ -- (BOOL)getObjectValue:(out id __nullable * __nullable)obj forString:(NSString *)string errorDescription:(out NSString * __nullable * __nullable)error; +- (BOOL)getObjectValue:(out id __nullable *__nullable)obj + forString:(NSString *)string + errorDescription:(out NSString *__nullable *__nullable)error; @end diff --git a/platform/darwin/src/MLNCustomDrawableStyleLayer.h b/platform/darwin/src/MLNCustomDrawableStyleLayer.h index df671349c..9d1b701af 100644 --- a/platform/darwin/src/MLNCustomDrawableStyleLayer.h +++ b/platform/darwin/src/MLNCustomDrawableStyleLayer.h @@ -1,10 +1,9 @@ #import #import "MLNFoundation.h" -#import "MLNFoundation.h" -#import "MLNStyleValue.h" -#import "MLNStyleLayer.h" #import "MLNGeometry.h" +#import "MLNStyleLayer.h" +#import "MLNStyleValue.h" MLN_EXPORT @interface MLNCustomDrawableStyleLayer : MLNStyleLayer diff --git a/platform/darwin/src/MLNCustomDrawableStyleLayer_Private.h b/platform/darwin/src/MLNCustomDrawableStyleLayer_Private.h index 9b03bbbd9..97fb9186c 100644 --- a/platform/darwin/src/MLNCustomDrawableStyleLayer_Private.h +++ b/platform/darwin/src/MLNCustomDrawableStyleLayer_Private.h @@ -5,11 +5,11 @@ #include namespace mbgl { - + class CustomDrawableStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::CustomDrawableLayerFactory { // LayerPeerFactory overrides. LayerFactory* getCoreLayerFactory() final { return this; } virtual MLNStyleLayer* createPeer(style::Layer*) final; }; - -} // namespace mbgl + +} // namespace mbgl diff --git a/platform/darwin/src/MLNCustomStyleLayer.h b/platform/darwin/src/MLNCustomStyleLayer.h index 135f3923d..666013d14 100644 --- a/platform/darwin/src/MLNCustomStyleLayer.h +++ b/platform/darwin/src/MLNCustomStyleLayer.h @@ -1,11 +1,11 @@ -#import #import +#import #import #import "MLNFoundation.h" -#import "MLNStyleValue.h" -#import "MLNStyleLayer.h" #import "MLNGeometry.h" +#import "MLNStyleLayer.h" +#import "MLNStyleValue.h" #if MLN_RENDER_BACKEND_METAL #import @@ -17,13 +17,13 @@ NS_ASSUME_NONNULL_BEGIN @class MLNStyle; typedef struct MLNStyleLayerDrawingContext { - CGSize size; - CLLocationCoordinate2D centerCoordinate; - double zoomLevel; - CLLocationDirection direction; - CGFloat pitch; - CGFloat fieldOfView; - MLNMatrix4 projectionMatrix; + CGSize size; + CLLocationCoordinate2D centerCoordinate; + double zoomLevel; + CLLocationDirection direction; + CGFloat pitch; + CGFloat fieldOfView; + MLNMatrix4 projectionMatrix; } MLNStyleLayerDrawingContext; MLN_EXPORT diff --git a/platform/darwin/src/MLNCustomStyleLayer_Private.h b/platform/darwin/src/MLNCustomStyleLayer_Private.h index 39ce4d339..6f11934ac 100644 --- a/platform/darwin/src/MLNCustomStyleLayer_Private.h +++ b/platform/darwin/src/MLNCustomStyleLayer_Private.h @@ -5,11 +5,11 @@ #include namespace mbgl { - + class CustomStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::CustomLayerFactory { // LayerPeerFactory overrides. LayerFactory* getCoreLayerFactory() final { return this; } virtual MLNStyleLayer* createPeer(style::Layer*) final; }; - -} // namespace mbgl + +} // namespace mbgl diff --git a/platform/darwin/src/MLNDefaultStyle.h b/platform/darwin/src/MLNDefaultStyle.h index 1f019f845..eb582c658 100644 --- a/platform/darwin/src/MLNDefaultStyle.h +++ b/platform/darwin/src/MLNDefaultStyle.h @@ -13,12 +13,12 @@ MLN_EXPORT /** The style URL */ -@property (nonatomic,retain) NSURL* url; +@property (nonatomic, retain) NSURL* url; /** The style name */ -@property (nonatomic,retain) NSString* name; +@property (nonatomic, retain) NSString* name; /** The style version diff --git a/platform/darwin/src/MLNDistanceFormatter.h b/platform/darwin/src/MLNDistanceFormatter.h index 498d03957..4f18f4448 100644 --- a/platform/darwin/src/MLNDistanceFormatter.h +++ b/platform/darwin/src/MLNDistanceFormatter.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" @@ -15,7 +15,7 @@ MLN_EXPORT /** Returns a localized formatted string for the provided distance. - + @param distance The distance, measured in meters. @return A localized formatted distance string including units. */ diff --git a/platform/darwin/src/MLNFeature.h b/platform/darwin/src/MLNFeature.h index 2917f73f4..a3815ac41 100644 --- a/platform/darwin/src/MLNFeature.h +++ b/platform/darwin/src/MLNFeature.h @@ -1,12 +1,12 @@ #import +#import "MLNCluster.h" #import "MLNFoundation.h" -#import "MLNPolyline.h" -#import "MLNPolygon.h" #import "MLNPointAnnotation.h" #import "MLNPointCollection.h" +#import "MLNPolygon.h" +#import "MLNPolyline.h" #import "MLNShapeCollection.h" -#import "MLNCluster.h" NS_ASSUME_NONNULL_BEGIN @@ -50,7 +50,8 @@ NS_ASSUME_NONNULL_BEGIN In vector tiles loaded by `MLNVectorTileSource` objects, the identifier corresponds to the - feature identifier + feature + identifier (`id`). If the source does not specify the feature’s identifier, the value of this property is `nil`. If specified, the identifier may be an integer, floating-point number, or string. These data types are mapped to instances of @@ -61,9 +62,10 @@ NS_ASSUME_NONNULL_BEGIN In the tile sourceThis property - Integer NSNumber (use the unsignedLongLongValue or longLongValue property) - Floating-point number NSNumber (use the doubleValue property) - String NSString + Integer NSNumber (use the + unsignedLongLongValue or longLongValue property) + Floating-point number NSNumber (use the doubleValue + property) String NSString @@ -98,7 +100,7 @@ NS_ASSUME_NONNULL_BEGIN `MLNShapeSource` using an `MLNCircleStyleLayer`, you can assign a `halfway` attribute to each of the source’s features, then set `MLNCircleStyleLayer.circleRadius` to an expression for the key path `halfway`. - + The `MLNSymbolStyleLayer.text` and `MLNSymbolStyleLayer.iconImageName` properties allow you to use attributes yet another way. For example, to label features in an `MLNShapeSource` object by their names, you can assign a `name` @@ -120,10 +122,11 @@ NS_ASSUME_NONNULL_BEGIN Null NSNull - Boolean NSNumber (use the boolValue property) - Integer NSNumber (use the unsignedLongLongValue or longLongValue property) - Floating-point number NSNumber (use the doubleValue property) - String NSString + Boolean NSNumber (use the boolValue + property) Integer NSNumber (use the + unsignedLongLongValue or longLongValue property) + Floating-point number NSNumber (use the doubleValue + property) String NSString @@ -133,7 +136,7 @@ NS_ASSUME_NONNULL_BEGIN and Mapbox Terrain layer references. - + When adding a feature to an `MLNShapeSource`, use the same Foundation types listed above for each attribute value. In addition to the Foundation types, you may also set an attribute to an `NSColor` (macOS) or `UIColor` (iOS), which @@ -183,7 +186,7 @@ MLN_EXPORT /** An `MLNPointFeature` object associates a point shape with an optional identifier and attributes. - + #### Related examples TODO: Dynamically style interactive points, learn how to initialize `MLNPointFeature` objects and add them to your map. @@ -195,9 +198,9 @@ MLN_EXPORT /** An `MLNPointFeatureCluster` object associates a point shape (with an optional identifier and attributes) and represents a point cluster. - + @see `MLNCluster` - + #### Related examples TODO: Clustering point data, learn how to initialize clusters and add them to your map. @@ -213,7 +216,7 @@ MLN_EXPORT A polyline feature is known as a LineString feature in GeoJSON. - + #### Related examples TODO: Add a line annotation from GeoJSON, learn how to initialize an `MLNPolylineFeature` and add it to an `MLNMapView` object. @@ -268,7 +271,7 @@ MLN_EXPORT /** An `MLNShapeCollectionFeature` object associates a shape collection with an optional identifier and attributes. - + `MLNShapeCollectionFeature` is most commonly used to add multiple shapes to a single `MLNShapeSource`. Configure the appearance of an `MLNSource`’s shape collection collectively using an `MLNSymbolStyleLayer` object, or use multiple @@ -279,7 +282,7 @@ MLN_EXPORT A shape collection feature is known as a feature collection in GeoJSON. - + #### Related examples TODO: Add multiple shapes from a single shape source, learn how to add shape data to your map using an `MLNShapeCollectionFeature` object. diff --git a/platform/darwin/src/MLNFeature_Private.h b/platform/darwin/src/MLNFeature_Private.h index b62154736..d792e270c 100644 --- a/platform/darwin/src/MLNFeature_Private.h +++ b/platform/darwin/src/MLNFeature_Private.h @@ -1,10 +1,10 @@ -#import "MLNFoundation.h" #import "MLNFeature.h" +#import "MLNFoundation.h" #import "MLNShape.h" -#import -#import #import +#import +#import NS_ASSUME_NONNULL_BEGIN @@ -13,73 +13,79 @@ NS_ASSUME_NONNULL_BEGIN vector tile features. */ MLN_EXPORT -NSArray *> *MLNFeaturesFromMBGLFeatures(const std::vector &features); +NSArray *> *MLNFeaturesFromMBGLFeatures( + const std::vector &features); /** Returns an array of `MLNFeature` objects converted from the given vector of vector tile features. */ MLN_EXPORT -NSArray *> *MLNFeaturesFromMBGLFeatures(const std::vector &features); +NSArray *> *MLNFeaturesFromMBGLFeatures( + const std::vector &features); /** Returns an `MLNFeature` object converted from the given mbgl::GeoJSONFeature */ MLN_EXPORT -id MLNFeatureFromMBGLFeature(const mbgl::GeoJSONFeature &feature); +id MLNFeatureFromMBGLFeature(const mbgl::GeoJSONFeature &feature); /** Returns an `MLNShape` representing the given geojson. The shape can be a feature, a collection of features, or a geometry. */ -MLNShape* MLNShapeFromGeoJSON(const mapbox::geojson::geojson &geojson); +MLNShape *MLNShapeFromGeoJSON(const mapbox::geojson::geojson &geojson); /** Takes an `mbgl::GeoJSONFeature` object, an identifer, and attributes dictionary and returns the feature object with converted `mbgl::FeatureIdentifier` and `mbgl::PropertyMap` properties. */ -mbgl::GeoJSONFeature mbglFeature(mbgl::GeoJSONFeature feature, id identifier, NSDictionary * attributes); +mbgl::GeoJSONFeature mbglFeature(mbgl::GeoJSONFeature feature, id identifier, + NSDictionary *attributes); /** Returns an `NSDictionary` representation of an `MLNFeature`. */ -NSDictionary *NSDictionaryFeatureForGeometry(NSDictionary *geometry, NSDictionary *attributes, id identifier); +NSDictionary *NSDictionaryFeatureForGeometry(NSDictionary *geometry, + NSDictionary *attributes, + id identifier); NS_ASSUME_NONNULL_END -#define MLN_DEFINE_FEATURE_INIT_WITH_CODER() \ - - (instancetype)initWithCoder:(NSCoder *)decoder { \ - if (self = [super initWithCoder:decoder]) { \ - NSSet *identifierClasses = [NSSet setWithArray:@[[NSString class], [NSNumber class]]]; \ - identifier = [decoder decodeObjectOfClasses:identifierClasses forKey:@"identifier"]; \ - _attributes = [decoder decodeObjectOfClass:[NSDictionary class] forKey:@"attributes"]; \ - } \ - return self; \ - } +#define MLN_DEFINE_FEATURE_INIT_WITH_CODER() \ + -(instancetype)initWithCoder : (NSCoder *)decoder { \ + if (self = [super initWithCoder:decoder]) { \ + NSSet *identifierClasses = \ + [NSSet setWithArray:@[ [NSString class], [NSNumber class] ]]; \ + identifier = [decoder decodeObjectOfClasses:identifierClasses forKey:@"identifier"]; \ + _attributes = [decoder decodeObjectOfClass:[NSDictionary class] forKey:@"attributes"]; \ + } \ + return self; \ + } -#define MLN_DEFINE_FEATURE_ENCODE() \ - - (void)encodeWithCoder:(NSCoder *)coder { \ - [super encodeWithCoder:coder]; \ - [coder encodeObject:identifier forKey:@"identifier"]; \ - [coder encodeObject:_attributes forKey:@"attributes"]; \ - } +#define MLN_DEFINE_FEATURE_ENCODE() \ + -(void)encodeWithCoder : (NSCoder *)coder { \ + [super encodeWithCoder:coder]; \ + [coder encodeObject:identifier forKey:@"identifier"]; \ + [coder encodeObject:_attributes forKey:@"attributes"]; \ + } -#define MLN_DEFINE_FEATURE_IS_EQUAL() \ - - (BOOL)isEqual:(id)other { \ - if (other == self) return YES; \ - if (![other isKindOfClass:[self class]]) return NO; \ - __typeof(self) otherFeature = other; \ - return [super isEqual:other] && [self geoJSONObject] == [otherFeature geoJSONObject]; \ - } \ - - (NSUInteger)hash { \ - return [super hash] + [[self geoJSONDictionary] hash]; \ - } +#define MLN_DEFINE_FEATURE_IS_EQUAL() \ + -(BOOL)isEqual : (id)other { \ + if (other == self) return YES; \ + if (![other isKindOfClass:[self class]]) return NO; \ + __typeof(self) otherFeature = other; \ + return [super isEqual:other] && [self geoJSONObject] == [otherFeature geoJSONObject]; \ + } \ + -(NSUInteger)hash { \ + return [super hash] + [[self geoJSONDictionary] hash]; \ + } #define MLN_DEFINE_FEATURE_ATTRIBUTES_GETTER() \ - - (NSDictionary *) attributes { \ - if (!_attributes) { \ - return @{}; \ - } \ - return _attributes; \ - } + -(NSDictionary *)attributes { \ + if (!_attributes) { \ + return @{}; \ + } \ + return _attributes; \ + } diff --git a/platform/darwin/src/MLNForegroundStyleLayer.h b/platform/darwin/src/MLNForegroundStyleLayer.h index 10308218c..3bd909330 100644 --- a/platform/darwin/src/MLNForegroundStyleLayer.h +++ b/platform/darwin/src/MLNForegroundStyleLayer.h @@ -22,7 +22,8 @@ MLN_EXPORT // MARK: Initializing a Style Layer -- (instancetype)init __attribute__((unavailable("Use -init methods of concrete subclasses instead."))); +- (instancetype)init + __attribute__((unavailable("Use -init methods of concrete subclasses instead."))); // MARK: Specifying a Style Layer’s Content diff --git a/platform/darwin/src/MLNFoundation.h b/platform/darwin/src/MLNFoundation.h index f3ec8c27c..39fa456d4 100644 --- a/platform/darwin/src/MLNFoundation.h +++ b/platform/darwin/src/MLNFoundation.h @@ -2,4 +2,4 @@ #import -#define MLN_EXPORT __attribute__((visibility ("default"))) +#define MLN_EXPORT __attribute__((visibility("default"))) diff --git a/platform/darwin/src/MLNFoundation_Private.h b/platform/darwin/src/MLNFoundation_Private.h index 31b38cc1a..530570b3a 100644 --- a/platform/darwin/src/MLNFoundation_Private.h +++ b/platform/darwin/src/MLNFoundation_Private.h @@ -5,15 +5,14 @@ void MLNInitializeRunLoop(); /* Using a compound statement (GNU Extension, supported by clang) */ -#define MLN_OBJC_DYNAMIC_CAST(object, type) \ - ({ \ - __typeof__( object ) temp##__LINE__ = (object); \ - (type *)([temp##__LINE__ isKindOfClass:[type class]] ? temp##__LINE__ : nil); \ - }) - -#define MLN_OBJC_DYNAMIC_CAST_AS_PROTOCOL(object, proto) \ - ({ \ - __typeof__( object ) temp##__LINE__ = (object); \ - (id< proto >)([temp##__LINE__ conformsToProtocol:@protocol( proto )] ? temp##__LINE__ : nil); \ - }) +#define MLN_OBJC_DYNAMIC_CAST(object, type) \ + ({ \ + __typeof__(object) temp##__LINE__ = (object); \ + (type *)([temp##__LINE__ isKindOfClass:[type class]] ? temp##__LINE__ : nil); \ + }) +#define MLN_OBJC_DYNAMIC_CAST_AS_PROTOCOL(object, proto) \ + ({ \ + __typeof__(object) temp##__LINE__ = (object); \ + (id)([temp##__LINE__ conformsToProtocol:@protocol(proto)] ? temp##__LINE__ : nil); \ + }) diff --git a/platform/darwin/src/MLNGeometry.h b/platform/darwin/src/MLNGeometry.h index 18a4c88e5..de1fc55dc 100644 --- a/platform/darwin/src/MLNGeometry.h +++ b/platform/darwin/src/MLNGeometry.h @@ -1,6 +1,6 @@ -#import -#import #import +#import +#import #import "MLNFoundation.h" @@ -8,59 +8,61 @@ NS_ASSUME_NONNULL_BEGIN /** Defines the area spanned by an `MLNCoordinateBounds`. */ typedef struct __attribute__((objc_boxable)) MLNCoordinateSpan { - /** Latitudes spanned by an `MLNCoordinateBounds`. */ - CLLocationDegrees latitudeDelta; - /** Longitudes spanned by an `MLNCoordinateBounds`. */ - CLLocationDegrees longitudeDelta; + /** Latitudes spanned by an `MLNCoordinateBounds`. */ + CLLocationDegrees latitudeDelta; + /** Longitudes spanned by an `MLNCoordinateBounds`. */ + CLLocationDegrees longitudeDelta; } MLNCoordinateSpan; /* Defines a point on the map in Mercator projection for a specific zoom level. */ typedef struct __attribute__((objc_boxable)) MLNMapPoint { - /** X coordinate representing a longitude in Mercator projection. */ - CGFloat x; - /** Y coordinate representing a latitide in Mercator projection. */ - CGFloat y; - /** Zoom level at which the X and Y coordinates are valid. */ - CGFloat zoomLevel; + /** X coordinate representing a longitude in Mercator projection. */ + CGFloat x; + /** Y coordinate representing a latitide in Mercator projection. */ + CGFloat y; + /** Zoom level at which the X and Y coordinates are valid. */ + CGFloat zoomLevel; } MLNMapPoint; /* Defines a 4x4 matrix. */ typedef struct MLNMatrix4 { - double m00, m01, m02, m03; - double m10, m11, m12, m13; - double m20, m21, m22, m23; - double m30, m31, m32, m33; + double m00, m01, m02, m03; + double m10, m11, m12, m13; + double m20, m21, m22, m23; + double m30, m31, m32, m33; } MLNMatrix4; /** Creates a new `MLNCoordinateSpan` from the given latitudinal and longitudinal deltas. */ -NS_INLINE MLNCoordinateSpan MLNCoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta) { - MLNCoordinateSpan span; - span.latitudeDelta = latitudeDelta; - span.longitudeDelta = longitudeDelta; - return span; +NS_INLINE MLNCoordinateSpan MLNCoordinateSpanMake(CLLocationDegrees latitudeDelta, + CLLocationDegrees longitudeDelta) { + MLNCoordinateSpan span; + span.latitudeDelta = latitudeDelta; + span.longitudeDelta = longitudeDelta; + return span; } /** Creates a new `MLNMapPoint` from the given X and Y coordinates, and zoom level. */ NS_INLINE MLNMapPoint MLNMapPointMake(CGFloat x, CGFloat y, CGFloat zoomLevel) { - MLNMapPoint point; - point.x = x; - point.y = y; - point.zoomLevel = zoomLevel; - return point; + MLNMapPoint point; + point.x = x; + point.y = y; + point.zoomLevel = zoomLevel; + return point; } /** Returns `YES` if the two coordinate spans represent the same latitudinal change and the same longitudinal change. */ -NS_INLINE BOOL MLNCoordinateSpanEqualToCoordinateSpan(MLNCoordinateSpan span1, MLNCoordinateSpan span2) { - return (span1.latitudeDelta == span2.latitudeDelta && - span1.longitudeDelta == span2.longitudeDelta); +NS_INLINE BOOL MLNCoordinateSpanEqualToCoordinateSpan(MLNCoordinateSpan span1, + MLNCoordinateSpan span2) { + return (span1.latitudeDelta == span2.latitudeDelta && + span1.longitudeDelta == span2.longitudeDelta); } /** An area of zero width and zero height. */ @@ -68,52 +70,55 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNCoordinateSpan MLNCoordinateSpanZero; /** A rectangular area as measured on a two-dimensional map projection. */ typedef struct __attribute__((objc_boxable)) MLNCoordinateBounds { - /** Coordinate at the southwest corner. */ - CLLocationCoordinate2D sw; - /** Coordinate at the northeast corner. */ - CLLocationCoordinate2D ne; + /** Coordinate at the southwest corner. */ + CLLocationCoordinate2D sw; + /** Coordinate at the northeast corner. */ + CLLocationCoordinate2D ne; } MLNCoordinateBounds; -/** +/** A quadrilateral area as measured on a two-dimensional map projection. `MLNCoordinateQuad` differs from `MLNCoordinateBounds` in that it allows representation of non-axis aligned bounds and non-rectangular quadrilaterals. The coordinates are described in counter clockwise order from top left. */ typedef struct MLNCoordinateQuad { - /** Coordinate at the top left corner. */ - CLLocationCoordinate2D topLeft; - /** Coordinate at the bottom left corner. */ - CLLocationCoordinate2D bottomLeft; - /** Coordinate at the bottom right corner. */ - CLLocationCoordinate2D bottomRight; - /** Coordinate at the top right corner. */ - CLLocationCoordinate2D topRight; + /** Coordinate at the top left corner. */ + CLLocationCoordinate2D topLeft; + /** Coordinate at the bottom left corner. */ + CLLocationCoordinate2D bottomLeft; + /** Coordinate at the bottom right corner. */ + CLLocationCoordinate2D bottomRight; + /** Coordinate at the top right corner. */ + CLLocationCoordinate2D topRight; } MLNCoordinateQuad; - /** Creates a new `MLNCoordinateBounds` structure from the given southwest and northeast coordinates. */ -NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsMake(CLLocationCoordinate2D sw, CLLocationCoordinate2D ne) { - MLNCoordinateBounds bounds; - bounds.sw = sw; - bounds.ne = ne; - return bounds; +NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsMake(CLLocationCoordinate2D sw, + CLLocationCoordinate2D ne) { + MLNCoordinateBounds bounds; + bounds.sw = sw; + bounds.ne = ne; + return bounds; } /** Creates a new `MLNCoordinateQuad` structure from the given top left, bottom left, bottom right, and top right coordinates. */ -NS_INLINE MLNCoordinateQuad MLNCoordinateQuadMake(CLLocationCoordinate2D topLeft, CLLocationCoordinate2D bottomLeft, CLLocationCoordinate2D bottomRight, CLLocationCoordinate2D topRight) { - MLNCoordinateQuad quad; - quad.topLeft = topLeft; - quad.bottomLeft = bottomLeft; - quad.bottomRight = bottomRight; - quad.topRight = topRight; - return quad; +NS_INLINE MLNCoordinateQuad MLNCoordinateQuadMake(CLLocationCoordinate2D topLeft, + CLLocationCoordinate2D bottomLeft, + CLLocationCoordinate2D bottomRight, + CLLocationCoordinate2D topRight) { + MLNCoordinateQuad quad; + quad.topLeft = topLeft; + quad.bottomLeft = bottomLeft; + quad.bottomRight = bottomRight; + quad.topRight = topRight; + return quad; } /** @@ -122,62 +127,63 @@ NS_INLINE MLNCoordinateQuad MLNCoordinateQuadMake(CLLocationCoordinate2D topLeft southwest coordinate at the bottom left. */ NS_INLINE MLNCoordinateQuad MLNCoordinateQuadFromCoordinateBounds(MLNCoordinateBounds bounds) { - MLNCoordinateQuad quad; - quad.topLeft = CLLocationCoordinate2DMake(bounds.ne.latitude, bounds.sw.longitude); - quad.bottomLeft = bounds.sw; - quad.bottomRight = CLLocationCoordinate2DMake(bounds.sw.latitude, bounds.ne.longitude); - quad.topRight = bounds.ne; - return quad; + MLNCoordinateQuad quad; + quad.topLeft = CLLocationCoordinate2DMake(bounds.ne.latitude, bounds.sw.longitude); + quad.bottomLeft = bounds.sw; + quad.bottomRight = CLLocationCoordinate2DMake(bounds.sw.latitude, bounds.ne.longitude); + quad.topRight = bounds.ne; + return quad; } /** Returns `YES` if the two coordinate bounds are equal to each other. */ -NS_INLINE BOOL MLNCoordinateBoundsEqualToCoordinateBounds(MLNCoordinateBounds bounds1, MLNCoordinateBounds bounds2) { - return (bounds1.sw.latitude == bounds2.sw.latitude && - bounds1.sw.longitude == bounds2.sw.longitude && - bounds1.ne.latitude == bounds2.ne.latitude && - bounds1.ne.longitude == bounds2.ne.longitude); +NS_INLINE BOOL MLNCoordinateBoundsEqualToCoordinateBounds(MLNCoordinateBounds bounds1, + MLNCoordinateBounds bounds2) { + return ( + bounds1.sw.latitude == bounds2.sw.latitude && bounds1.sw.longitude == bounds2.sw.longitude && + bounds1.ne.latitude == bounds2.ne.latitude && bounds1.ne.longitude == bounds2.ne.longitude); } /** Returns `YES` if the two coordinate bounds intersect. */ -NS_INLINE BOOL MLNCoordinateBoundsIntersectsCoordinateBounds(MLNCoordinateBounds bounds1, MLNCoordinateBounds bounds2) { - return (bounds1.ne.latitude > bounds2.sw.latitude && - bounds1.sw.latitude < bounds2.ne.latitude && - bounds1.ne.longitude > bounds2.sw.longitude && - bounds1.sw.longitude < bounds2.ne.longitude); +NS_INLINE BOOL MLNCoordinateBoundsIntersectsCoordinateBounds(MLNCoordinateBounds bounds1, + MLNCoordinateBounds bounds2) { + return (bounds1.ne.latitude > bounds2.sw.latitude && bounds1.sw.latitude < bounds2.ne.latitude && + bounds1.ne.longitude > bounds2.sw.longitude && + bounds1.sw.longitude < bounds2.ne.longitude); } /** Returns `YES` if the coordinate is within the coordinate bounds. - + #### Related examples TODO: Restrict map panning to an area, learn how to use `MLNCoordinateInCoordinateBounds` to determine if a point is within, or intersects, a given bounding box. */ -NS_INLINE BOOL MLNCoordinateInCoordinateBounds(CLLocationCoordinate2D coordinate, MLNCoordinateBounds bounds) { - return (coordinate.latitude >= bounds.sw.latitude && - coordinate.latitude <= bounds.ne.latitude && - coordinate.longitude >= bounds.sw.longitude && - coordinate.longitude <= bounds.ne.longitude); +NS_INLINE BOOL MLNCoordinateInCoordinateBounds(CLLocationCoordinate2D coordinate, + MLNCoordinateBounds bounds) { + return (coordinate.latitude >= bounds.sw.latitude && coordinate.latitude <= bounds.ne.latitude && + coordinate.longitude >= bounds.sw.longitude && + coordinate.longitude <= bounds.ne.longitude); } /** Returns the area spanned by the coordinate bounds. */ NS_INLINE MLNCoordinateSpan MLNCoordinateBoundsGetCoordinateSpan(MLNCoordinateBounds bounds) { - return MLNCoordinateSpanMake(bounds.ne.latitude - bounds.sw.latitude, - bounds.ne.longitude - bounds.sw.longitude); + return MLNCoordinateSpanMake(bounds.ne.latitude - bounds.sw.latitude, + bounds.ne.longitude - bounds.sw.longitude); } /** Returns a coordinate bounds with southwest and northeast coordinates that are offset from those of the source bounds. */ -NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsOffset(MLNCoordinateBounds bounds, MLNCoordinateSpan offset) { - MLNCoordinateBounds offsetBounds = bounds; - offsetBounds.sw.latitude += offset.latitudeDelta; - offsetBounds.sw.longitude += offset.longitudeDelta; - offsetBounds.ne.latitude += offset.latitudeDelta; - offsetBounds.ne.longitude += offset.longitudeDelta; - return offsetBounds; +NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsOffset(MLNCoordinateBounds bounds, + MLNCoordinateSpan offset) { + MLNCoordinateBounds offsetBounds = bounds; + offsetBounds.sw.latitude += offset.latitudeDelta; + offsetBounds.sw.longitude += offset.longitudeDelta; + offsetBounds.ne.latitude += offset.latitudeDelta; + offsetBounds.ne.longitude += offset.longitudeDelta; + return offsetBounds; } /** @@ -187,56 +193,60 @@ NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsOffset(MLNCoordinateBounds boun northeast point lies due north of its southwest point). */ NS_INLINE BOOL MLNCoordinateBoundsIsEmpty(MLNCoordinateBounds bounds) { - MLNCoordinateSpan span = MLNCoordinateBoundsGetCoordinateSpan(bounds); - return span.latitudeDelta == 0 || span.longitudeDelta == 0; + MLNCoordinateSpan span = MLNCoordinateBoundsGetCoordinateSpan(bounds); + return span.latitudeDelta == 0 || span.longitudeDelta == 0; } /** Returns a formatted string for the given coordinate bounds. */ NS_INLINE NSString *MLNStringFromCoordinateBounds(MLNCoordinateBounds bounds) { - return [NSString stringWithFormat:@"{ sw = {%.1f, %.1f}, ne = {%.1f, %.1f}}", - bounds.sw.latitude, bounds.sw.longitude, - bounds.ne.latitude, bounds.ne.longitude]; + return [NSString stringWithFormat:@"{ sw = {%.1f, %.1f}, ne = {%.1f, %.1f}}", bounds.sw.latitude, + bounds.sw.longitude, bounds.ne.latitude, bounds.ne.longitude]; } /** Returns a formatted string for the given coordinate quad. */ NS_INLINE NSString *MLNStringFromCoordinateQuad(MLNCoordinateQuad quad) { - return [NSString stringWithFormat:@"{ topleft = {%.1f, %.1f}, bottomleft = {%.1f, %.1f}}, bottomright = {%.1f, %.1f}, topright = {%.1f, %.1f}", - quad.topLeft.latitude, quad.topLeft.longitude, - quad.bottomLeft.latitude, quad.bottomLeft.longitude, - quad.bottomRight.latitude, quad.bottomRight.longitude, - quad.topRight.latitude, quad.topRight.longitude]; + return [NSString stringWithFormat:@"{ topleft = {%.1f, %.1f}, bottomleft = {%.1f, %.1f}}, " + @"bottomright = {%.1f, %.1f}, topright = {%.1f, %.1f}", + quad.topLeft.latitude, quad.topLeft.longitude, + quad.bottomLeft.latitude, quad.bottomLeft.longitude, + quad.bottomRight.latitude, quad.bottomRight.longitude, + quad.topRight.latitude, quad.topRight.longitude]; } /** Returns radians, converted from degrees. */ NS_INLINE CGFloat MLNRadiansFromDegrees(CLLocationDegrees degrees) { - return (CGFloat)(degrees * M_PI) / 180; + return (CGFloat)(degrees * M_PI) / 180; } /** Returns degrees, converted from radians. */ -NS_INLINE CLLocationDegrees MLNDegreesFromRadians(CGFloat radians) { - return radians * 180 / M_PI; -} +NS_INLINE CLLocationDegrees MLNDegreesFromRadians(CGFloat radians) { return radians * 180 / M_PI; } /** Returns Mercator projection of a WGS84 coordinate at the specified zoom level. */ -FOUNDATION_EXTERN MLN_EXPORT MLNMapPoint MLNMapPointForCoordinate(CLLocationCoordinate2D coordinate, double zoomLevel); - +FOUNDATION_EXTERN MLN_EXPORT MLNMapPoint MLNMapPointForCoordinate(CLLocationCoordinate2D coordinate, + double zoomLevel); /** Converts a map zoom level to a camera altitude. - + @param zoomLevel The zoom level to convert. @param pitch The camera pitch, measured in degrees. @param latitude The latitude of the point at the center of the viewport. @param size The size of the viewport. @return An altitude measured in meters. */ -FOUNDATION_EXTERN MLN_EXPORT CLLocationDistance MLNAltitudeForZoomLevel(double zoomLevel, CGFloat pitch, CLLocationDegrees latitude, CGSize size); +FOUNDATION_EXTERN MLN_EXPORT CLLocationDistance MLNAltitudeForZoomLevel(double zoomLevel, + CGFloat pitch, + CLLocationDegrees latitude, + CGSize size); /** Converts a camera altitude to a map zoom level. - + @param altitude The altitude to convert, measured in meters. @param pitch The camera pitch, measured in degrees. @param latitude The latitude of the point at the center of the viewport. @param size The size of the viewport. @return A zero-based zoom level. */ -FOUNDATION_EXTERN MLN_EXPORT double MLNZoomLevelForAltitude(CLLocationDistance altitude, CGFloat pitch, CLLocationDegrees latitude, CGSize size); +FOUNDATION_EXTERN MLN_EXPORT double MLNZoomLevelForAltitude(CLLocationDistance altitude, + CGFloat pitch, + CLLocationDegrees latitude, + CGSize size); NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MLNGeometry_Private.h b/platform/darwin/src/MLNGeometry_Private.h index 29e3157ff..ffff02d8e 100644 --- a/platform/darwin/src/MLNGeometry_Private.h +++ b/platform/darwin/src/MLNGeometry_Private.h @@ -2,7 +2,7 @@ #import #if TARGET_OS_IPHONE - #import +#import #endif #import @@ -15,18 +15,19 @@ typedef double MLNRadianDirection; /** Defines the coordinate by a `MLNRadianCoordinate2D`. */ typedef struct MLNRadianCoordinate2D { - MLNLocationRadians latitude; - MLNLocationRadians longitude; + MLNLocationRadians latitude; + MLNLocationRadians longitude; } MLNRadianCoordinate2D; /** Creates a new `MLNRadianCoordinate2D` from the given latitudinal and longitudinal. */ -NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinate2DMake(MLNLocationRadians latitude, MLNLocationRadians longitude) { - MLNRadianCoordinate2D radianCoordinate; - radianCoordinate.latitude = latitude; - radianCoordinate.longitude = longitude; - return radianCoordinate; +NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinate2DMake(MLNLocationRadians latitude, + MLNLocationRadians longitude) { + MLNRadianCoordinate2D radianCoordinate; + radianCoordinate.latitude = latitude; + radianCoordinate.longitude = longitude; + return radianCoordinate; } /// Returns the smallest rectangle that contains both the given rectangle and @@ -34,55 +35,51 @@ NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinate2DMake(MLNLocationRadians lat CGRect MLNExtendRect(CGRect rect, CGPoint point); #if TARGET_OS_IPHONE -NS_INLINE NSString *MLNStringFromSize(CGSize size) { - return NSStringFromCGSize(size); -} +NS_INLINE NSString *MLNStringFromSize(CGSize size) { return NSStringFromCGSize(size); } #else -NS_INLINE NSString *MLNStringFromSize(NSSize size) { - return NSStringFromSize(size); -} +NS_INLINE NSString *MLNStringFromSize(NSSize size) { return NSStringFromSize(size); } #endif NS_INLINE NSString *MLNStringFromCLLocationCoordinate2D(CLLocationCoordinate2D coordinate) { - return [NSString stringWithFormat:@"(lat: %f, lon: %f)", coordinate.latitude, coordinate.longitude]; + return + [NSString stringWithFormat:@"(lat: %f, lon: %f)", coordinate.latitude, coordinate.longitude]; } mbgl::LatLng MLNLatLngFromLocationCoordinate2D(CLLocationCoordinate2D coordinate); NS_INLINE mbgl::Point MLNPointFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) { - return mbgl::Point(coordinate.longitude, coordinate.latitude); + return mbgl::Point(coordinate.longitude, coordinate.latitude); } NS_INLINE CLLocationCoordinate2D MLNLocationCoordinate2DFromPoint(mbgl::Point point) { - return CLLocationCoordinate2DMake(point.y, point.x); + return CLLocationCoordinate2DMake(point.y, point.x); } NS_INLINE CLLocationCoordinate2D MLNLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) { - return CLLocationCoordinate2DMake(latLng.latitude(), latLng.longitude()); + return CLLocationCoordinate2DMake(latLng.latitude(), latLng.longitude()); } NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsFromLatLngBounds(mbgl::LatLngBounds latLngBounds) { - return MLNCoordinateBoundsMake(MLNLocationCoordinate2DFromLatLng(latLngBounds.southwest()), - MLNLocationCoordinate2DFromLatLng(latLngBounds.northeast())); + return MLNCoordinateBoundsMake(MLNLocationCoordinate2DFromLatLng(latLngBounds.southwest()), + MLNLocationCoordinate2DFromLatLng(latLngBounds.northeast())); } -NS_INLINE mbgl::LatLngBounds MLNLatLngBoundsFromCoordinateBounds(MLNCoordinateBounds coordinateBounds) { - return mbgl::LatLngBounds::hull(MLNLatLngFromLocationCoordinate2D(coordinateBounds.sw), - MLNLatLngFromLocationCoordinate2D(coordinateBounds.ne)); +NS_INLINE mbgl::LatLngBounds MLNLatLngBoundsFromCoordinateBounds( + MLNCoordinateBounds coordinateBounds) { + return mbgl::LatLngBounds::hull(MLNLatLngFromLocationCoordinate2D(coordinateBounds.sw), + MLNLatLngFromLocationCoordinate2D(coordinateBounds.ne)); } NS_INLINE std::array MLNLatLngArrayFromCoordinateQuad(MLNCoordinateQuad quad) { - return { MLNLatLngFromLocationCoordinate2D(quad.topLeft), - MLNLatLngFromLocationCoordinate2D(quad.topRight), - MLNLatLngFromLocationCoordinate2D(quad.bottomRight), - MLNLatLngFromLocationCoordinate2D(quad.bottomLeft) }; + return {MLNLatLngFromLocationCoordinate2D(quad.topLeft), + MLNLatLngFromLocationCoordinate2D(quad.topRight), + MLNLatLngFromLocationCoordinate2D(quad.bottomRight), + MLNLatLngFromLocationCoordinate2D(quad.bottomLeft)}; } NS_INLINE MLNCoordinateQuad MLNCoordinateQuadFromLatLngArray(std::array quad) { - return { MLNLocationCoordinate2DFromLatLng(quad[0]), - MLNLocationCoordinate2DFromLatLng(quad[3]), - MLNLocationCoordinate2DFromLatLng(quad[2]), - MLNLocationCoordinate2DFromLatLng(quad[1]) }; + return {MLNLocationCoordinate2DFromLatLng(quad[0]), MLNLocationCoordinate2DFromLatLng(quad[3]), + MLNLocationCoordinate2DFromLatLng(quad[2]), MLNLocationCoordinate2DFromLatLng(quad[1])}; } /** @@ -90,51 +87,50 @@ NS_INLINE MLNCoordinateQuad MLNCoordinateQuadFromLatLngArray(std::array= -90.0 && - coordinate.longitude <= 360.0 && - coordinate.longitude >= -360.0); + return (coordinate.latitude <= 90.0 && coordinate.latitude >= -90.0 && + coordinate.longitude <= 360.0 && coordinate.longitude >= -360.0); } #if TARGET_OS_IPHONE - #define MLNEdgeInsets UIEdgeInsets - #define MLNEdgeInsetsMake UIEdgeInsetsMake +#define MLNEdgeInsets UIEdgeInsets +#define MLNEdgeInsetsMake UIEdgeInsetsMake #else - #define MLNEdgeInsets NSEdgeInsets - #define MLNEdgeInsetsMake NSEdgeInsetsMake +#define MLNEdgeInsets NSEdgeInsets +#define MLNEdgeInsetsMake NSEdgeInsetsMake #endif NS_INLINE mbgl::EdgeInsets MLNEdgeInsetsFromNSEdgeInsets(MLNEdgeInsets insets) { - return { insets.top, insets.left, insets.bottom, insets.right }; + return {insets.top, insets.left, insets.bottom, insets.right}; } -NS_INLINE MLNEdgeInsets NSEdgeInsetsFromMLNEdgeInsets(const mbgl::EdgeInsets& insets) { - return MLNEdgeInsetsMake(insets.top(), insets.left(), insets.bottom(), insets.right()); +NS_INLINE MLNEdgeInsets NSEdgeInsetsFromMLNEdgeInsets(const mbgl::EdgeInsets &insets) { + return MLNEdgeInsetsMake(insets.top(), insets.left(), insets.bottom(), insets.right()); } /// Returns the combination of two edge insets. NS_INLINE MLNEdgeInsets MLNEdgeInsetsInsetEdgeInset(MLNEdgeInsets base, MLNEdgeInsets inset) { - return MLNEdgeInsetsMake(base.top + inset.top, - base.left + inset.left, - base.bottom + inset.bottom, - base.right + inset.right); + return MLNEdgeInsetsMake(base.top + inset.top, base.left + inset.left, base.bottom + inset.bottom, + base.right + inset.right); } /** Returns MLNRadianCoordinate2D, converted from CLLocationCoordinate2D. */ -NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinateFromLocationCoordinate(CLLocationCoordinate2D locationCoordinate) { - return MLNRadianCoordinate2DMake(MLNRadiansFromDegrees(locationCoordinate.latitude), - MLNRadiansFromDegrees(locationCoordinate.longitude)); +NS_INLINE MLNRadianCoordinate2D +MLNRadianCoordinateFromLocationCoordinate(CLLocationCoordinate2D locationCoordinate) { + return MLNRadianCoordinate2DMake(MLNRadiansFromDegrees(locationCoordinate.latitude), + MLNRadiansFromDegrees(locationCoordinate.longitude)); } /** Returns the distance in radians given two coordinates. */ -MLNRadianDistance MLNDistanceBetweenRadianCoordinates(MLNRadianCoordinate2D from, MLNRadianCoordinate2D to); +MLNRadianDistance MLNDistanceBetweenRadianCoordinates(MLNRadianCoordinate2D from, + MLNRadianCoordinate2D to); /** Returns direction in radians given two coordinates. */ -MLNRadianDirection MLNRadianCoordinatesDirection(MLNRadianCoordinate2D from, MLNRadianCoordinate2D to); +MLNRadianDirection MLNRadianCoordinatesDirection(MLNRadianCoordinate2D from, + MLNRadianCoordinate2D to); /** Returns a coordinate at a given distance and direction away from coordinate. @@ -146,7 +142,8 @@ MLNRadianCoordinate2D MLNRadianCoordinateAtDistanceFacingDirection(MLNRadianCoor /** Returns the direction from one coordinate to another. */ -CLLocationDirection MLNDirectionBetweenCoordinates(CLLocationCoordinate2D firstCoordinate, CLLocationCoordinate2D secondCoordinate); +CLLocationDirection MLNDirectionBetweenCoordinates(CLLocationCoordinate2D firstCoordinate, + CLLocationCoordinate2D secondCoordinate); /** Returns a point with coordinates rounded to the nearest logical pixel. diff --git a/platform/darwin/src/MLNImageSource.h b/platform/darwin/src/MLNImageSource.h index 36165809f..cd46ee16e 100644 --- a/platform/darwin/src/MLNImageSource.h +++ b/platform/darwin/src/MLNImageSource.h @@ -1,8 +1,8 @@ #import "MLNSource.h" #import "MLNFoundation.h" -#import "MLNTypes.h" #import "MLNGeometry.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -10,19 +10,19 @@ MLN_EXPORT /** `MLNImageSource` is a content source that is used for a georeferenced raster image to be shown on the map. The georeferenced image scales and rotates as the - user zooms and rotates the map. Images may also be used as icons or patterns - in a style layer. To register an image for use as an icon or pattern, - use the `-[MLNStyle setImage:forName:]` method. To configure a point + user zooms and rotates the map. Images may also be used as icons or patterns + in a style layer. To register an image for use as an icon or pattern, + use the `-[MLNStyle setImage:forName:]` method. To configure a point annotation’s image, use the `MLNAnnotationImage` class. - - The geographic location of the raster image content, supplied with + + The geographic location of the raster image content, supplied with `MLNCoordinateQuad`, can be non-axis aligned. - `MLNImageSource` supports raster content from `NSURL`, `NSImage` (macOS), or + `MLNImageSource` supports raster content from `NSURL`, `NSImage` (macOS), or `UIImage` (iOS). An image source is added to an `MLNStyle` object along with one or more `MLNRasterStyleLayer` objects. Use a raster style layer to control the appearance of content supplied by the image source. - + Each image source defined by the style JSON file is represented at runtime by an @@ -38,10 +38,10 @@ MLN_EXPORT bottomLeft: CLLocationCoordinate2D(latitude: 37.936, longitude: -80.425), bottomRight: CLLocationCoordinate2D(latitude: 37.936, longitude: -71.516), topRight: CLLocationCoordinate2D(latitude: 46.437, longitude: -71.516)) - let source = MLNImageSource(identifier: "radar", coordinateQuad: coordinates, url: URL(string: "https://maplibre.org/maplibre-gl-js-docs/assets/radar.gif")!) - mapView.style?.addSource(source) + let source = MLNImageSource(identifier: "radar", coordinateQuad: coordinates, url: URL(string: + "https://maplibre.org/maplibre-gl-js-docs/assets/radar.gif")!) mapView.style?.addSource(source) ``` - + #### Related examples TODO: Add an image, learn how to add an image to your map using `MLNImageSource`. */ @@ -54,22 +54,28 @@ MLN_EXPORT Returns a georeferenced image source with an identifier, coordinates and a URL. @param identifier A string that uniquely identifies the source. - @param coordinateQuad the top left, top right, bottom right, and bottom left coordinates for the image. + @param coordinateQuad the top left, top right, bottom right, and bottom left coordinates for the + image. @param url An HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle. @return An initialized shape source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier coordinateQuad:(MLNCoordinateQuad)coordinateQuad URL:(NSURL *)url; +- (instancetype)initWithIdentifier:(NSString *)identifier + coordinateQuad:(MLNCoordinateQuad)coordinateQuad + URL:(NSURL *)url; /** Returns a georeferenced image source with an identifier, coordinates and an image. @param identifier A string that uniquely identifies the source. - @param coordinateQuad The top left, top right, bottom right, and bottom left coordinates for the image. + @param coordinateQuad The top left, top right, bottom right, and bottom left coordinates for the + image. @param image The image to display for the source. @return An initialized shape source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier coordinateQuad:(MLNCoordinateQuad)coordinateQuad image:(MLNImage *)image; +- (instancetype)initWithIdentifier:(NSString *)identifier + coordinateQuad:(MLNCoordinateQuad)coordinateQuad + image:(MLNImage *)image; // MARK: Accessing a Source’s Content @@ -79,7 +85,7 @@ MLN_EXPORT If the receiver was initialized using `-initWithIdentifier:coordinateQuad:image:` or the `image` property is set, this property is set to `nil`. */ -@property (nonatomic, copy, nullable)NSURL *URL; +@property (nonatomic, copy, nullable) NSURL *URL; /** Sets the URL for the image source, performing necessary validations. @@ -91,9 +97,10 @@ MLN_EXPORT /** The source image. - If the receiver was initialized using `-initWithIdentifier:coordinateQuad:URL:` or if the `URL` property is set, this property is set to `nil`. + If the receiver was initialized using `-initWithIdentifier:coordinateQuad:URL:` or if the `URL` + property is set, this property is set to `nil`. */ -@property (nonatomic, retain, nullable)MLNImage *image; +@property (nonatomic, retain, nullable) MLNImage *image; /** The coordinates at which the corners of the source image will be placed. diff --git a/platform/darwin/src/MLNLight_Private.h b/platform/darwin/src/MLNLight_Private.h index 0525dc3ef..4882bb810 100644 --- a/platform/darwin/src/MLNLight_Private.h +++ b/platform/darwin/src/MLNLight_Private.h @@ -3,10 +3,10 @@ #import "MLNLight.h" namespace mbgl { - namespace style { - class Light; - } +namespace style { +class Light; } +} // namespace mbgl @interface MLNLight (Private) diff --git a/platform/darwin/src/MLNLocationManager.h b/platform/darwin/src/MLNLocationManager.h index 9616a3d72..760f5e96c 100644 --- a/platform/darwin/src/MLNLocationManager.h +++ b/platform/darwin/src/MLNLocationManager.h @@ -1,5 +1,5 @@ -#import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN such as a change in the user’s location. This protocol is similar to the Core Location framework’s `CLLocationManager` class, but your implementation does not need to be based on `CLLocationManager`. - + To receive location updates from an object that conforms to the `MLNLocationManager` protocol, use the optional methods available in the `MLNLocationManagerDelegate` protocol. */ @@ -25,10 +25,10 @@ NS_ASSUME_NONNULL_BEGIN /** Specifies the minimum distance (measured in meters) a device must move horizontally before a location update is generated. - + The default value of this property is `kCLDistanceFilterNone` when `MLNMapView` uses its default location manager. - + @see `CLLocationManager.distanceFilter` */ - (CLLocationDistance)distanceFilter; @@ -37,23 +37,23 @@ NS_ASSUME_NONNULL_BEGIN Sets the minimum update distance in meters. @param distanceFilter The distance filter in meters. */ -- (void)setDistanceFilter:(CLLocationDistance) distanceFilter; +- (void)setDistanceFilter:(CLLocationDistance)distanceFilter; /** Specifies the accuracy of the location data. - + The default value is `kCLLocationAccuracyBest` when `MLNMapView` uses its default location manager. - + @note Determining a location with greater accuracy requires more time and more power. - + @see `CLLocationManager.desiredAccuracy` */ - (CLLocationAccuracy)desiredAccuracy; /** Sets the desired location accuracy. - + @param desiredAccuracy The desired location accuracy. */ - (void)setDesiredAccuracy:(CLLocationAccuracy)desiredAccuracy; @@ -61,31 +61,31 @@ NS_ASSUME_NONNULL_BEGIN #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 /** Specifies the level of location accuracy the Maps SDK has permission to use. - + @note If the value of this property is `CLAccuracyAuthorizationFullAccuracy`, you can set the - `MLNLocationManager.desiredAccuracy` property to any value. If the value is `CLAccuracyAuthorizationReducedAccuracy`, - setting `MLNLocationManager.desiredAccuracy` to a value other than` kCLLocationAccuracyReduced` has no effect on - the location information. + `MLNLocationManager.desiredAccuracy` property to any value. If the value is + `CLAccuracyAuthorizationReducedAccuracy`, setting `MLNLocationManager.desiredAccuracy` to a value + other than` kCLLocationAccuracyReduced` has no effect on the location information. */ - (CLAccuracyAuthorization)accuracyAuthorization API_AVAILABLE(ios(14)); #endif /** Specifies the type of user activity associated with the location updates. - + The location manager uses this property as a cue to determine when location updates may be automatically paused. - + The default value is `CLActivityTypeOther` when `MLNMapView` uses its default location manager. - + @see `CLLocationManager.activityType` */ - (CLActivityType)activityType; /** Sets the type of user activity associated with the location updates. - + @param activityType The location's manager activity type. */ - (void)setActivityType:(CLActivityType)activityType; @@ -94,18 +94,19 @@ NS_ASSUME_NONNULL_BEGIN /** Requests the user's permission to temporarily use location update services with full accuracy. - + @note If the user turned off location accuracy you may use this method to request full accuracy for a session. */ -- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString *)purposeKey API_AVAILABLE(ios(14)); +- (void)requestTemporaryFullAccuracyAuthorizationWithPurposeKey:(NSString *)purposeKey + API_AVAILABLE(ios(14)); #endif @required /** The delegate to receive location updates. - + Do not set the location manager’s delegate yourself. `MLNMapView` sets this property after the location manager becomes `MLNMapView`’s location manager. */ @@ -115,7 +116,7 @@ NS_ASSUME_NONNULL_BEGIN /** Returns the current localization authorization status. - + @see `+[CLLocationManger authorizationStatus]` */ @property (nonatomic, readonly) CLAuthorizationStatus authorizationStatus; @@ -180,7 +181,7 @@ NS_ASSUME_NONNULL_BEGIN /** Notifies the delegate with the new location data. - + @param manager The location manager reporting the update. @param locations An array of `CLLocation` objects in chronological order, with the last object representing the most recent location. This array @@ -194,16 +195,15 @@ NS_ASSUME_NONNULL_BEGIN /** Notifies the delegate with the new heading data. - + @param manager The location manager reporting the update. @param newHeading The new heading update. */ -- (void)locationManager:(id)manager - didUpdateHeading:(CLHeading *)newHeading; +- (void)locationManager:(id)manager didUpdateHeading:(CLHeading *)newHeading; /** Asks the delegate if the calibration alert should be displayed. - + @param manager The location manager reporting the calibration. */ - (BOOL)locationManagerShouldDisplayHeadingCalibration:(id)manager; @@ -213,21 +213,20 @@ NS_ASSUME_NONNULL_BEGIN /** Notifies the delegate that the location manager was unable to retrieve location updates. - + @param manager The location manager reporting the error. @param error An error object containing the error code that indicates why the location manager failed. */ -- (void)locationManager:(id)manager - didFailWithError:(nonnull NSError *)error; +- (void)locationManager:(id)manager didFailWithError:(nonnull NSError *)error; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 140000 /** Notifies the delegate that the location authorization status has changed. - + @param manager The location manager reporting the change. */ - (void)locationManagerDidChangeAuthorization:(id)manager; -#endif +#endif @optional diff --git a/platform/darwin/src/MLNLocationManager_Private.h b/platform/darwin/src/MLNLocationManager_Private.h index b4ee94de0..af6e7edd0 100644 --- a/platform/darwin/src/MLNLocationManager_Private.h +++ b/platform/darwin/src/MLNLocationManager_Private.h @@ -1,5 +1,5 @@ #import "MLNLocationManager.h" -@interface MLNCLLocationManager : NSObject +@interface MLNCLLocationManager : NSObject @end diff --git a/platform/darwin/src/MLNLoggingConfiguration.h b/platform/darwin/src/MLNLoggingConfiguration.h index 3bc310b32..8d6be8e94 100644 --- a/platform/darwin/src/MLNLoggingConfiguration.h +++ b/platform/darwin/src/MLNLoggingConfiguration.h @@ -3,11 +3,11 @@ #import "MLNFoundation.h" #ifndef MLN_LOGGING_DISABLED - #ifndef MLN_LOGGING_ENABLE_DEBUG - #ifndef NDEBUG - #define MLN_LOGGING_ENABLE_DEBUG 1 - #endif - #endif +#ifndef MLN_LOGGING_ENABLE_DEBUG +#ifndef NDEBUG +#define MLN_LOGGING_ENABLE_DEBUG 1 +#endif +#endif NS_ASSUME_NONNULL_BEGIN @@ -15,50 +15,51 @@ NS_ASSUME_NONNULL_BEGIN Constants indicating the message's logging level. */ typedef NS_ENUM(NSInteger, MLNLoggingLevel) { - /** - None-level won't print any messages. - */ - MLNLoggingLevelNone = 0, - /** - Fault-level messages contain system-level error information. - */ - MLNLoggingLevelFault, - /** - Error-level messages contain information that is intended to aid in process-level - errors. - */ - MLNLoggingLevelError, - /** - Warning-level messages contain warning information for potential risks. - */ - MLNLoggingLevelWarning, - /** - Info-level messages contain information that may be helpful for flow tracing - but is not essential. - */ - MLNLoggingLevelInfo, - /** - Debug-level messages contain information that may be helpful for troubleshooting - specific problems. - */ + /** + None-level won't print any messages. + */ + MLNLoggingLevelNone = 0, + /** + Fault-level messages contain system-level error information. + */ + MLNLoggingLevelFault, + /** + Error-level messages contain information that is intended to aid in process-level + errors. + */ + MLNLoggingLevelError, + /** + Warning-level messages contain warning information for potential risks. + */ + MLNLoggingLevelWarning, + /** + Info-level messages contain information that may be helpful for flow tracing + but is not essential. + */ + MLNLoggingLevelInfo, +/** + Debug-level messages contain information that may be helpful for troubleshooting + specific problems. + */ #if MLN_LOGGING_ENABLE_DEBUG - MLNLoggingLevelDebug, + MLNLoggingLevelDebug, #endif - /** - Verbose-level will print all messages. - */ - MLNLoggingLevelVerbose, + /** + Verbose-level will print all messages. + */ + MLNLoggingLevelVerbose, }; /** A block to be called once `loggingLevel` is set to a higher value than `MLNLoggingLevelNone`. - + @param loggingLevel The message logging level. @param filePath The description of the file and method for the calling message. @param line The line where the message is logged. @param message The logging message. */ -typedef void (^MLNLoggingBlockHandler)(MLNLoggingLevel loggingLevel, NSString *filePath, NSUInteger line, NSString *message); +typedef void (^MLNLoggingBlockHandler)(MLNLoggingLevel loggingLevel, NSString *filePath, + NSUInteger line, NSString *message); /** The `MLNLoggingConfiguration` object provides a global way to set this SDK logging levels @@ -69,19 +70,19 @@ MLN_EXPORT /** The handler this SDK uses to log messages. - + If this property is set to nil or if no custom handler is provided this property is set to the default handler. - + The default handler uses `os_log` and `NSLog` for iOS 10+ and iOS < 10 respectively. */ @property (nonatomic, copy, null_resettable) MLNLoggingBlockHandler handler; /** The logging level. - + The default value is `MLNLoggingLevelNone`. - + Setting this property includes logging levels less than or equal to the setted value. */ @property (assign, nonatomic) MLNLoggingLevel loggingLevel; diff --git a/platform/darwin/src/MLNLoggingConfiguration_Private.h b/platform/darwin/src/MLNLoggingConfiguration_Private.h index 3b8bbce83..0d17b0cb4 100644 --- a/platform/darwin/src/MLNLoggingConfiguration_Private.h +++ b/platform/darwin/src/MLNLoggingConfiguration_Private.h @@ -1,12 +1,11 @@ #import "MLNLoggingConfiguration.h" -NS_INLINE NSString *MLNStringFromBOOL(BOOL value) { - return value ? @"YES" : @"NO"; -} +NS_INLINE NSString *MLNStringFromBOOL(BOOL value) { return value ? @"YES" : @"NO"; } #if TARGET_OS_OSX NS_INLINE NSString *MLNStringFromNSEdgeInsets(NSEdgeInsets insets) { - return [NSString stringWithFormat:@"{ top: %f, left: %f, bottom: %f, right: %f", insets.top, insets.left, insets.bottom, insets.right]; + return [NSString stringWithFormat:@"{ top: %f, left: %f, bottom: %f, right: %f", insets.top, + insets.left, insets.bottom, insets.right]; } #endif @@ -21,47 +20,57 @@ NS_INLINE NSString *MLNStringFromNSEdgeInsets(NSEdgeInsets insets) { #else #if MLN_LOGGING_ENABLE_DEBUG - #define MLNLogDebug(message, ...) MLNLogWithType(MLNLoggingLevelDebug, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MLNLogDebug(message, ...) \ + MLNLogWithType(MLNLoggingLevelDebug, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) #else - #define MLNLogDebug(...) +#define MLNLogDebug(...) #endif -#define MLNLogInfo(message, ...) MLNLogWithType(MLNLoggingLevelInfo, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) -#define MLNLogWarning(message, ...) MLNLogWithType(MLNLoggingLevelWarning, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) -#define MLNLogError(message, ...) MLNLogWithType(MLNLoggingLevelError, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) -#define MLNLogFault(message, ...) MLNLogWithType(MLNLoggingLevelFault, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MLNLogInfo(message, ...) \ + MLNLogWithType(MLNLoggingLevelInfo, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MLNLogWarning(message, ...) \ + MLNLogWithType(MLNLoggingLevelWarning, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MLNLogError(message, ...) \ + MLNLogWithType(MLNLoggingLevelError, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MLNLogFault(message, ...) \ + MLNLogWithType(MLNLoggingLevelFault, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) #endif -#define MLNAssert(expression, message, ...) \ - __extension__({ \ - if (__builtin_expect(!(expression), 0)) { \ - MLNLogFault(message, ##__VA_ARGS__); \ - } \ - NSAssert(expression, message, ##__VA_ARGS__); \ - }) -#define MLNCAssert(expression, message, ...) \ - __extension__({ \ - if (__builtin_expect(!(expression), 0)) { \ - MLNLogFault(message, ##__VA_ARGS__); \ - } \ - NSCAssert(expression, message, ##__VA_ARGS__); \ - }) - +#define MLNAssert(expression, message, ...) \ + __extension__({ \ + if (__builtin_expect(!(expression), 0)) { \ + MLNLogFault(message, ##__VA_ARGS__); \ + } \ + NSAssert(expression, message, ##__VA_ARGS__); \ + }) +#define MLNCAssert(expression, message, ...) \ + __extension__({ \ + if (__builtin_expect(!(expression), 0)) { \ + MLNLogFault(message, ##__VA_ARGS__); \ + } \ + NSCAssert(expression, message, ##__VA_ARGS__); \ + }) #ifndef MLN_LOGGING_DISABLED -#define MLNLogWithType(type, function, line, message, ...) \ -{ \ - if ([MLNLoggingConfiguration sharedConfiguration].loggingLevel != MLNLoggingLevelNone && type <= [MLNLoggingConfiguration sharedConfiguration].loggingLevel) \ - { \ - [[MLNLoggingConfiguration sharedConfiguration] logCallingFunction:function functionLine:line messageType:type format:(message), ##__VA_ARGS__]; \ - } \ -} +#define MLNLogWithType(type, function, line, message, ...) \ + { \ + if ([MLNLoggingConfiguration sharedConfiguration].loggingLevel != MLNLoggingLevelNone && \ + type <= [MLNLoggingConfiguration sharedConfiguration].loggingLevel) { \ + [[MLNLoggingConfiguration sharedConfiguration] logCallingFunction:function \ + functionLine:line \ + messageType:type \ + format:(message), ##__VA_ARGS__]; \ + } \ + } @interface MLNLoggingConfiguration (Private) -- (void)logCallingFunction:(const char *)callingFunction functionLine:(NSUInteger)functionLine messageType:(MLNLoggingLevel)type format:(id)messageFormat, ...; +- (void)logCallingFunction:(const char *)callingFunction + functionLine:(NSUInteger)functionLine + messageType:(MLNLoggingLevel)type + format:(id)messageFormat, ...; @end #endif diff --git a/platform/darwin/src/MLNMapCamera.h b/platform/darwin/src/MLNMapCamera.h index e65a03a55..c6db09314 100644 --- a/platform/darwin/src/MLNMapCamera.h +++ b/platform/darwin/src/MLNMapCamera.h @@ -1,6 +1,6 @@ -#import #import #import +#import #import "MLNFoundation.h" @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** An `MLNMapCamera` object represents a viewpoint from which the user observes some point on an `MLNMapView`. - + #### Related examples TODO: Camera animation, learn how to create a camera that rotates around a central point. @@ -34,10 +34,10 @@ MLN_EXPORT /** The altitude (measured in meters) above the map at which the camera is situated. - + The altitude is the distance from the viewpoint to the map, perpendicular to the map plane. This property does not account for physical elevation. - + This property’s value may be less than that of the `viewingDistance` property. Setting this property automatically updates the `viewingDistance` property based on the `pitch` property’s current value. @@ -46,7 +46,7 @@ MLN_EXPORT /** The straight-line distance from the viewpoint to the `centerCoordinate`. - + Setting this property automatically updates the `altitude` property based on the `pitch` property’s current value. */ @@ -73,11 +73,11 @@ MLN_EXPORT /** Returns a new camera with the given distance, pitch, and heading. - + This method interprets the distance as a straight-line distance from the viewpoint to the center coordinate. To specify the altitude of the viewpoint, use the `-cameraLookingAtCenterCoordinate:altitude:pitch:heading:` method. - + @param centerCoordinate The geographic coordinate on which the map should be centered. @param distance The straight-line distance from the viewpoint to the @@ -128,17 +128,17 @@ MLN_EXPORT fromDistance:(CLLocationDistance)distance pitch:(CGFloat)pitch heading:(CLLocationDirection)heading -__attribute__((deprecated("Use -cameraLookingAtCenterCoordinate:acrossDistance:pitch:heading: " - "or -cameraLookingAtCenterCoordinate:altitude:pitch:heading:."))); + __attribute__((deprecated("Use -cameraLookingAtCenterCoordinate:acrossDistance:pitch:heading: " + "or -cameraLookingAtCenterCoordinate:altitude:pitch:heading:."))); /** Returns a Boolean value indicating whether the given camera is functionally equivalent to the receiver. - + Unlike `-isEqual:`, this method returns `YES` if the difference between the coordinates, altitudes, pitches, or headings of the two camera objects is negligible. - + @param otherCamera The camera with which to compare the receiver. @return A Boolean value indicating whether the two cameras are functionally equivalent. diff --git a/platform/darwin/src/MLNMapSnapshotter.h b/platform/darwin/src/MLNMapSnapshotter.h index 1341f5ab7..ad2e4eb93 100644 --- a/platform/darwin/src/MLNMapSnapshotter.h +++ b/platform/darwin/src/MLNMapSnapshotter.h @@ -1,8 +1,8 @@ #import -#import "MLNTypes.h" #import "MLNGeometry.h" #import "MLNMapCamera.h" #import "MLNStyle.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -55,7 +55,7 @@ draw custom overlays rendered with Core Graphics. @param snapshotOverlay The `MLNMapSnapshotOverlay` provided during snapshot drawing. */ -typedef void (^MLNMapSnapshotOverlayHandler)(MLNMapSnapshotOverlay * snapshotOverlay); +typedef void (^MLNMapSnapshotOverlayHandler)(MLNMapSnapshotOverlay *snapshotOverlay); /** The options to use when creating images with the `MLNMapSnapshotter`. @@ -65,13 +65,15 @@ MLN_EXPORT /** Creates a set of options with the minimum required information. - + @param styleURL URL of the map style to snapshot. The URL may be a full HTTP, HTTPS URL, canonical URL or a path to a local file relative to the application’s resource path. Specify `nil` for the default style. @param size The image size. */ -- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL camera:(MLNMapCamera *)camera size:(CGSize)size; +- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL + camera:(MLNMapCamera *)camera + size:(CGSize)size; // MARK: - Configuring the Map @@ -82,7 +84,7 @@ MLN_EXPORT /** The zoom level. - + The default zoom level is 0. If this property is non-zero and the camera property is non-nil, the camera’s altitude is ignored in favor of this property’s value. @@ -91,7 +93,7 @@ MLN_EXPORT /** A camera representing the viewport visible in the snapshot. - + If this property is non-nil and the `coordinateBounds` property is set to a non-empty coordinate bounds, the camera’s center coordinate and altitude are ignored in favor of the `coordinateBounds` property. @@ -100,7 +102,7 @@ MLN_EXPORT /** The coordinate rectangle that encompasses the bounds to capture. - + If this property is non-empty and the camera property is non-nil, the camera’s center coordinate and altitude are ignored in favor of this property’s value. */ @@ -110,13 +112,13 @@ MLN_EXPORT /** The size of the output image, measured in points. - + */ @property (nonatomic, readonly) CGSize size; /** The scale of the output image. Defaults to the main screen scale. - + The minimum scale is 1. */ @property (nonatomic) CGFloat scale; @@ -157,7 +159,6 @@ MLN_EXPORT */ - (CLLocationCoordinate2D)coordinateForPoint:(NSPoint)point; - /** The image of the map’s content. */ @@ -168,12 +169,13 @@ MLN_EXPORT /** A block to processes the result or error of a snapshot request. - + @param snapshot The `MLNMapSnapshot` that was generated or `nil` if an error occurred. @param error The error that occured or `nil` when successful. */ -typedef void (^MLNMapSnapshotCompletionHandler)(MLNMapSnapshot* _Nullable snapshot, NSError* _Nullable error); +typedef void (^MLNMapSnapshotCompletionHandler)(MLNMapSnapshot *_Nullable snapshot, + NSError *_Nullable error); /** An `MLNMapSnapshotter` generates static raster images of the map. Each snapshot @@ -182,40 +184,41 @@ typedef void (^MLNMapSnapshotCompletionHandler)(MLNMapSnapshot* _Nullable snapsh asynchronously, calling `MLNMapSnapshotterDelegate` methods if defined, then passing it into a completion handler once tiles and other resources needed for the snapshot are finished loading. - + You can change the snapshotter’s options at any time and reuse the snapshotter for multiple distinct snapshots; however, the snapshotter can only generate one snapshot at a time. If you need to generate multiple snapshots concurrently, create multiple snapshotter objects. - + For an interactive map, use the `MLNMapView` class. Both `MLNMapSnapshotter` and `MLNMapView` are compatible with offline packs managed by the `MLNOfflineStorage` class. - + From a snapshot, you can obtain an image and convert geographic coordinates to the image’s coordinate space in order to superimpose markers and overlays. If you do not need offline map functionality, you can use the `Snapshot` class in [MapboxStatic.swift](https://github.com/mapbox/MapboxStatic.swift/) to generate static map images with overlays. - + ### Example - + ```swift - let camera = MLNMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0) - - let options = MLNMapSnapshotOptions(styleURL: MLNStyle.satelliteStreetsStyleURL, camera: camera, size: CGSize(width: 320, height: 480)) - options.zoomLevel = 10 - + let camera = MLNMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: + -122.4365), altitude: 100, pitch: 20, heading: 0) + + let options = MLNMapSnapshotOptions(styleURL: MLNStyle.satelliteStreetsStyleURL, camera: camera, + size: CGSize(width: 320, height: 480)) options.zoomLevel = 10 + let snapshotter = MLNMapSnapshotter(options: options) snapshotter.start { (snapshot, error) in if let error = error { fatalError(error.localizedDescription) } - + image = snapshot?.image } ``` - + #### Related examples TODO: Create a static map snapshot, learn how to use the `MLNMapSnapshotter` to generate a static image based on an `MLNMapView` @@ -229,7 +232,7 @@ MLN_EXPORT /** Initializes and returns a map snapshotter object that produces snapshots according to the given options. - + @param options The options to use when generating a map snapshot. @return An initialized map snapshotter. */ @@ -237,7 +240,7 @@ MLN_EXPORT /** Starts the snapshot creation and executes the specified block with the result. - + @param completionHandler The block to call with a finished snapshot. The block is executed on the main queue. */ @@ -246,19 +249,20 @@ MLN_EXPORT /** Starts the snapshot creation and executes the specified block with the result on the specified queue. - + @param queue The queue on which to call the block specified in the `completionHandler` parameter. @param completionHandler The block to call with a finished snapshot. The block is executed on the queue specified in the `queue` parameter. */ -- (void)startWithQueue:(dispatch_queue_t)queue completionHandler:(MLNMapSnapshotCompletionHandler)completionHandler; +- (void)startWithQueue:(dispatch_queue_t)queue + completionHandler:(MLNMapSnapshotCompletionHandler)completionHandler; /** Starts the snapshot creation and executes the specified blocks with the result on the specified queue. Use this option if you want to add custom drawing on top of the resulting `MLNMapSnapshot`. - + @param overlayHandler The block to call after the base map finishes drawing but before certain built-in overlays draw. The block can use Core Graphics to draw custom content directly over the base map. The block is executed on a @@ -266,11 +270,12 @@ MLN_EXPORT @param completionHandler The block to call with a finished snapshot. The block is executed on the main queue. */ -- (void)startWithOverlayHandler:(MLNMapSnapshotOverlayHandler)overlayHandler completionHandler:(MLNMapSnapshotCompletionHandler)completionHandler; +- (void)startWithOverlayHandler:(MLNMapSnapshotOverlayHandler)overlayHandler + completionHandler:(MLNMapSnapshotCompletionHandler)completionHandler; /** Cancels the snapshot creation request, if any. - + Once you call this method, you cannot resume the snapshot. In order to obtain the snapshot, create a new `MLNMapSnapshotter` object. */ @@ -288,24 +293,24 @@ MLN_EXPORT /** The snapshotter’s delegate. - + The delegate is responsible for responding to significant changes during the snapshotting process, such as the style loading. Implement a delegate to customize the style that is depicted by the snapshot. - + You set the delegate after initializing the snapshotter but before receiving the snapshot, typically before starting the snapshot. The snapshotter keeps a weak reference to its delegate, so you must keep a strong reference to it to ensure that your style customizations apply. */ -@property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id delegate; /** The style displayed in the resulting snapshot. - + Unlike the `MLNMapSnapshotOptions.styleURL` property, this property is set to an object that allows you to manipulate every aspect of the style locally. - + This property is set to `nil` until the style finishes loading. If the style has failed to load, this property is set to `nil`. Because the style loads asynchronously, you should manipulate it in the @@ -333,11 +338,11 @@ MLN_EXPORT /** Tells the delegate that the snapshotter was unable to load data needed for snapshotting the map. - + This method may be called for a variety of reasons, including a network connection failure or a failure to fetch the style from the server. You can use the given error message to notify the user that map data is unavailable. - + @param snapshotter The snapshotter that is unable to load the data. @param error The reason the data could not be loaded. */ @@ -345,12 +350,12 @@ MLN_EXPORT /** Tells the delegate that the snapshotter has just finished loading a style. - + This method is called in response to `-[MLNMapSnapshotter startWithQueue:completionHandler:]` as long as the `MLNMapSnapshotter.delegate` property is set. Changes to sources or layers of the style being snapshotted do not cause this method to be called. - + @param snapshotter The snapshotter that has just loaded a style. @param style The style that was loaded. */ diff --git a/platform/darwin/src/MLNMultiPoint.h b/platform/darwin/src/MLNMultiPoint.h index 76965df83..ff52480ac 100644 --- a/platform/darwin/src/MLNMultiPoint.h +++ b/platform/darwin/src/MLNMultiPoint.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" #import "MLNShape.h" @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN The `MLNMultiPoint` class is an abstract superclass used to define shapes composed of multiple vertices. - Create instances of `MLNPolyline` or `MLNPolygon` in order to use + Create instances of `MLNPolyline` or `MLNPolygon` in order to use properties of `MLNMultiPoint`. Do not create instances of `MLNMultiPoint` directly and do not create your own subclasses of this class. You can use the method and properties of this class to access information about the @@ -60,7 +60,7 @@ MLN_EXPORT /** Inserts the given vertices into the shape. - + If the shape is currently visible on the map as an annotation, it is redrawn immediately. If the shape is part of an `MLNShapeSource` object, you must explicitly set the `MLNShapeSource.shape` property in order for any style @@ -72,11 +72,13 @@ MLN_EXPORT @param index The zero-based index at which the first coordinate in `coords` will appear in the `coordinates` property. */ -- (void)insertCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count atIndex:(NSUInteger)index; +- (void)insertCoordinates:(const CLLocationCoordinate2D *)coords + count:(NSUInteger)count + atIndex:(NSUInteger)index; /** Appends the given vertices to the shape. - + If the shape is currently visible on the map as an annotation, it is redrawn immediately. If the shape is part of an `MLNShapeSource` object, you must explicitly set the `MLNShapeSource.shape` property in order for any style @@ -91,7 +93,7 @@ MLN_EXPORT /** Replaces the vertices at the given range in the shape with the same number of vertices from a given C array. - + If the shape is currently visible on the map as an annotation, it is redrawn immediately. If the shape is part of an `MLNShapeSource` object, you must explicitly set the `MLNShapeSource.shape` property in order for any style @@ -112,12 +114,13 @@ MLN_EXPORT @param coords The array of coordinates defining part of the shape. The data in this array is copied to the shape’s `coordinates` property. */ -- (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(const CLLocationCoordinate2D *)coords; +- (void)replaceCoordinatesInRange:(NSRange)range + withCoordinates:(const CLLocationCoordinate2D *)coords; /** Replaces the vertices at the given range in the shape with the specified number of vertices from a given C array. - + If the shape is currently visible on the map as an annotation, it is redrawn immediately. If the shape is part of an `MLNShapeSource` object, you must explicitly set the `MLNShapeSource.shape` property in order for any style @@ -142,11 +145,13 @@ MLN_EXPORT count must not exceed the number of items currently in the `coordinates` property. */ -- (void)replaceCoordinatesInRange:(NSRange)range withCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count; +- (void)replaceCoordinatesInRange:(NSRange)range + withCoordinates:(const CLLocationCoordinate2D *)coords + count:(NSUInteger)count; /** Removes the vertices at the given range from the shape. - + If the shape is currently visible on the map as an annotation, it is redrawn immediately. If the shape is part of an `MLNShapeSource` object, you must explicitly set the `MLNShapeSource.shape` property in order for any style diff --git a/platform/darwin/src/MLNMultiPoint_Private.h b/platform/darwin/src/MLNMultiPoint_Private.h index f27d96b63..deeb261df 100644 --- a/platform/darwin/src/MLNMultiPoint_Private.h +++ b/platform/darwin/src/MLNMultiPoint_Private.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)intersectsOverlayBounds:(MLNCoordinateBounds)overlayBounds; /** Constructs a shape annotation object, asking the delegate for style values. */ -- (mbgl::Annotation)annotationObjectWithDelegate:(id )delegate; +- (mbgl::Annotation)annotationObjectWithDelegate:(id)delegate; @end diff --git a/platform/darwin/src/MLNNetworkConfiguration.h b/platform/darwin/src/MLNNetworkConfiguration.h index 995766eb5..62c7af76f 100644 --- a/platform/darwin/src/MLNNetworkConfiguration.h +++ b/platform/darwin/src/MLNNetworkConfiguration.h @@ -26,7 +26,6 @@ NS_ASSUME_NONNULL_BEGIN - (NSURLSession *)sessionForNetworkConfiguration:(MLNNetworkConfiguration *)configuration; @end - /** The `MLNNetworkConfiguration` object provides a global way to set a base `NSURLSessionConfiguration`, and other resources. @@ -48,13 +47,13 @@ MLN_EXPORT /** The session configuration object that is used by the `NSURLSession` objects in this SDK. - + If this property is set to nil or if no session configuration is provided this property is set to the default session configuration. - + Assign this object before instantiating any `MLNMapView` object, or using `MLNOfflineStorage` - + @note `NSURLSession` objects store a copy of this configuration. Any further changes to mutable properties on this configuration object passed to a session’s initializer will not affect the behavior of that session. diff --git a/platform/darwin/src/MLNNetworkConfiguration_Private.h b/platform/darwin/src/MLNNetworkConfiguration_Private.h index 4d2478707..db4102b3e 100644 --- a/platform/darwin/src/MLNNetworkConfiguration_Private.h +++ b/platform/darwin/src/MLNNetworkConfiguration_Private.h @@ -1,20 +1,21 @@ -#import "MLNNetworkConfiguration.h" #include +#import "MLNNetworkConfiguration.h" NS_ASSUME_NONNULL_BEGIN @class MLNNetworkConfiguration; @protocol MLNNetworkConfigurationMetricsDelegate -- (void)networkConfiguration:(MLNNetworkConfiguration *)networkConfiguration didGenerateMetricEvent:(NSDictionary *)metricEvent; +- (void)networkConfiguration:(MLNNetworkConfiguration *)networkConfiguration + didGenerateMetricEvent:(NSDictionary *)metricEvent; @end -extern NSString * const kMLNDownloadPerformanceEvent; +extern NSString *const kMLNDownloadPerformanceEvent; @interface MLNNetworkConfiguration (Private) -@property (nonatomic, strong) NSMutableDictionary *events; +@property (nonatomic, strong) NSMutableDictionary *events; @property (nonatomic, weak) id metricsDelegate; - (void)resetNativeNetworkManagerDelegate; diff --git a/platform/darwin/src/MLNOfflinePack.h b/platform/darwin/src/MLNOfflinePack.h index 9b871ad4e..33857a3a1 100644 --- a/platform/darwin/src/MLNOfflinePack.h +++ b/platform/darwin/src/MLNOfflinePack.h @@ -1,8 +1,8 @@ #import #import "MLNFoundation.h" -#import "MLNTypes.h" #import "MLNOfflineRegion.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -11,46 +11,46 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNInvalidOfflinePackExcepti /** The state an offline pack is currently in. */ -typedef NS_ENUM (NSInteger, MLNOfflinePackState) { - /** - It is unknown whether the pack is inactive, active, or complete. +typedef NS_ENUM(NSInteger, MLNOfflinePackState) { + /** + It is unknown whether the pack is inactive, active, or complete. - This is the initial state of a pack. The state of a pack becomes known by - the time the shared `MLNOfflineStorage` object sends the first - `MLNOfflinePackProgressChangedNotification` about the pack. For inactive - packs, you must explicitly request a progress update using the - `-[MLNOfflinePack requestProgress]` method. + This is the initial state of a pack. The state of a pack becomes known by + the time the shared `MLNOfflineStorage` object sends the first + `MLNOfflinePackProgressChangedNotification` about the pack. For inactive + packs, you must explicitly request a progress update using the + `-[MLNOfflinePack requestProgress]` method. - An invalid pack always has a state of `MLNOfflinePackStateInvalid`, never - `MLNOfflinePackStateUnknown`. - */ - MLNOfflinePackStateUnknown = 0, - /** - The pack is incomplete and is not currently downloading. + An invalid pack always has a state of `MLNOfflinePackStateInvalid`, never + `MLNOfflinePackStateUnknown`. + */ + MLNOfflinePackStateUnknown = 0, + /** + The pack is incomplete and is not currently downloading. - This is the initial state of a pack that is created using the - `-[MLNOfflineStorage addPackForRegion:withContext:completionHandler:]` - method, as well as after the `-[MLNOfflinePack suspend]` method is - called. - */ - MLNOfflinePackStateInactive = 1, - /** - The pack is incomplete and is currently downloading. + This is the initial state of a pack that is created using the + `-[MLNOfflineStorage addPackForRegion:withContext:completionHandler:]` + method, as well as after the `-[MLNOfflinePack suspend]` method is + called. + */ + MLNOfflinePackStateInactive = 1, + /** + The pack is incomplete and is currently downloading. - This is the state of a pack after the `-[MLNOfflinePack resume]` method is - called. - */ - MLNOfflinePackStateActive = 2, - /** - The pack has downloaded to completion. - */ - MLNOfflinePackStateComplete = 3, - /** - The pack has been removed using the - `-[MLNOfflineStorage removePack:withCompletionHandler:]` method. Sending - any message to the pack will raise an exception. - */ - MLNOfflinePackStateInvalid = 4, + This is the state of a pack after the `-[MLNOfflinePack resume]` method is + called. + */ + MLNOfflinePackStateActive = 2, + /** + The pack has downloaded to completion. + */ + MLNOfflinePackStateComplete = 3, + /** + The pack has been removed using the + `-[MLNOfflineStorage removePack:withCompletionHandler:]` method. Sending + any message to the pack will raise an exception. + */ + MLNOfflinePackStateInvalid = 4, }; /** @@ -58,42 +58,42 @@ typedef NS_ENUM (NSInteger, MLNOfflinePackState) { progress. */ typedef struct __attribute__((objc_boxable)) MLNOfflinePackProgress { - /** - The number of resources, including tiles, that have been completely - downloaded and are ready to use offline. - */ - uint64_t countOfResourcesCompleted; - /** - The cumulative size of the downloaded resources on disk, including tiles, - measured in bytes. - */ - uint64_t countOfBytesCompleted; - /** - The number of tiles that have been completely downloaded and are ready - to use offline. - */ - uint64_t countOfTilesCompleted; - /** - The cumulative size of the downloaded tiles on disk, measured in bytes. - */ - uint64_t countOfTileBytesCompleted; - /** - The minimum number of resources that must be downloaded in order to view - the pack’s full region without any omissions. + /** + The number of resources, including tiles, that have been completely + downloaded and are ready to use offline. + */ + uint64_t countOfResourcesCompleted; + /** + The cumulative size of the downloaded resources on disk, including tiles, + measured in bytes. + */ + uint64_t countOfBytesCompleted; + /** + The number of tiles that have been completely downloaded and are ready + to use offline. + */ + uint64_t countOfTilesCompleted; + /** + The cumulative size of the downloaded tiles on disk, measured in bytes. + */ + uint64_t countOfTileBytesCompleted; + /** + The minimum number of resources that must be downloaded in order to view + the pack’s full region without any omissions. - At the beginning of a download, this count is a lower bound; the number of - expected resources may increase as the download progresses. - */ - uint64_t countOfResourcesExpected; - /** - The maximum number of resources that must be downloaded in order to view - the pack’s full region without any omissions. + At the beginning of a download, this count is a lower bound; the number of + expected resources may increase as the download progresses. + */ + uint64_t countOfResourcesExpected; + /** + The maximum number of resources that must be downloaded in order to view + the pack’s full region without any omissions. - At the beginning of a download, when the exact number of required resources - is unknown, this field is set to `UINT64_MAX`. Thus this count is always an - upper bound. - */ - uint64_t maximumResourcesExpected; + At the beginning of a download, when the exact number of required resources + is unknown, this field is set to `UINT64_MAX`. Thus this count is always an + upper bound. + */ + uint64_t maximumResourcesExpected; } MLNOfflinePackProgress; /** @@ -103,16 +103,16 @@ typedef struct __attribute__((objc_boxable)) MLNOfflinePackProgress { To create an instance of `MLNOfflinePack`, use the `+[MLNOfflineStorage addPackForRegion:withContext:completionHandler:]` method. A pack created using `-[MLNOfflinePack init]` is immediately invalid. - + ### Example ```swift MLNOfflineStorage.shared.addPack(for: region, withContext: context) { (pack, error) in guard let pack = pack else { // If adding the pack fails, log an error to console. - print("Error:", error?.localizedDescription ?? "unknown error adding pack at \(#file)(\(#line)) in \(#function)") - return + print("Error:", error?.localizedDescription ?? "unknown error adding pack at + \(#file)(\(#line)) in \(#function)") return } - + // Start an MLNOfflinePack download pack.resume() } @@ -124,14 +124,14 @@ MLN_EXPORT /** The region for which the pack manages resources. */ -@property (nonatomic, readonly) id region; +@property (nonatomic, readonly) id region; /** Arbitrary data stored alongside the downloaded resources. The context typically holds application-specific information for identifying the pack, such as a user-selected name. - + To change the value of this property, use the `-setContext:completionHandler:` method. If you access this property after calling that method but before its completion handler is called, this property’s value may not reflect the new @@ -142,16 +142,17 @@ MLN_EXPORT /** Associates arbitrary contextual data with the offline pack, replacing any context that was previously associated with the offline pack. - + Setting the context is asynchronous. The `context` property may not be updated until the completion handler is called. - + @param context The new context to associate with the offline pack. @param completion The completion handler to call when the context has been updated. If there is an error setting the context, the error is passed into the completion handler. */ -- (void)setContext:(NSData *)context completionHandler:(void (^_Nullable)(NSError * _Nullable error))completion; +- (void)setContext:(NSData *)context + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; /** The pack’s current state. diff --git a/platform/darwin/src/MLNOfflineRegion.h b/platform/darwin/src/MLNOfflineRegion.h index bf0c0b009..bb52445a3 100644 --- a/platform/darwin/src/MLNOfflineRegion.h +++ b/platform/darwin/src/MLNOfflineRegion.h @@ -10,10 +10,10 @@ NS_ASSUME_NONNULL_BEGIN /** URL of the style whose resources are required for offline viewing. - + In addition to the JSON stylesheet, different styles may require different font glyphs, sprite sheets, and other resources. - + The URL may be a full HTTP or HTTPS URL or a canonical URL */ @property (nonatomic, readonly) NSURL *styleURL; @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN instead of relying on fonts downloaded as part of the offline pack. See `MLNIdeographicFontFamilyName` setting. Also, for regions outside of China, Japan, and Korea, these glyphs will rarely appear for non-CJK users. - + By default, this property is set to `NO`, so that the offline pack will include ideographic glyphs. */ diff --git a/platform/darwin/src/MLNOfflineStorage.h b/platform/darwin/src/MLNOfflineStorage.h index 09cdf623e..3a7853c06 100644 --- a/platform/darwin/src/MLNOfflineStorage.h +++ b/platform/darwin/src/MLNOfflineStorage.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN If you only need to observe changes in a particular pack’s progress, you can alternatively observe KVO change notifications to the pack’s `progress` key path. - + #### Related examples TODO: Download an offline map, learn how to calculate the progress of an offline download. @@ -58,7 +58,8 @@ FOUNDATION_EXTERN MLN_EXPORT const NSNotificationName MLNOfflinePackErrorNotific additional tiles from Mapbox APIs until already downloaded tiles are removed by calling the `-[MLNOfflineStorage removePack:withCompletionHandler:]` method. */ -FOUNDATION_EXTERN MLN_EXPORT const NSNotificationName MLNOfflinePackMaximumMapboxTilesReachedNotification; +FOUNDATION_EXTERN MLN_EXPORT const NSNotificationName + MLNOfflinePackMaximumMapboxTilesReachedNotification; /** A key in the `userInfo` property of a notification posted by `MLNOfflinePack`. @@ -114,7 +115,8 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNUnsupportedRegionTypeExce @param error Contains a pointer to an error object (if any) indicating why the pack could not be created or added. */ -typedef void (^MLNOfflinePackAdditionCompletionHandler)(MLNOfflinePack * _Nullable pack, NSError * _Nullable error); +typedef void (^MLNOfflinePackAdditionCompletionHandler)(MLNOfflinePack *_Nullable pack, + NSError *_Nullable error); /** A block to be called once an offline pack has been completely invalidated and @@ -127,11 +129,11 @@ typedef void (^MLNOfflinePackAdditionCompletionHandler)(MLNOfflinePack * _Nullab @param error Contains a pointer to an error object (if any) indicating why the pack could not be invalidated or removed. */ -typedef void (^MLNOfflinePackRemovalCompletionHandler)(NSError * _Nullable error); +typedef void (^MLNOfflinePackRemovalCompletionHandler)(NSError *_Nullable error); /** A block to be called once the contents of a file are copied into the current packs. - + @param fileURL The file URL of the offline database containing the offline packs that were copied. @param packs An array of all known offline packs, or `nil` if there was an error @@ -139,7 +141,8 @@ typedef void (^MLNOfflinePackRemovalCompletionHandler)(NSError * _Nullable error @param error A pointer to an error object (if any) indicating why the pack could not be created or added. */ -typedef void (^MLNBatchedOfflinePackAdditionCompletionHandler)(NSURL *fileURL, NSArray * _Nullable packs, NSError * _Nullable error); +typedef void (^MLNBatchedOfflinePackAdditionCompletionHandler)( + NSURL *fileURL, NSArray *_Nullable packs, NSError *_Nullable error); /** A block to be called once the data has been preloaded. @@ -148,32 +151,32 @@ A block to be called once the data has been preloaded. @param error Contains a pointer to an error object (if any) indicating why the data could not be pre-loaded. */ -typedef void (^MLNOfflinePreloadDataCompletionHandler)(NSURL * url, NSError * _Nullable error); +typedef void (^MLNOfflinePreloadDataCompletionHandler)(NSURL *url, NSError *_Nullable error); /** The type of resource that is requested. */ typedef NS_ENUM(NSUInteger, MLNResourceKind) { - /** Unknown type */ - MLNResourceKindUnknown, - /** Style sheet JSON file */ - MLNResourceKindStyle, - /** TileJSON file as specified in https://maplibre.org/maplibre-style-spec/root/#sources */ - MLNResourceKindSource, - /** A vector or raster tile as described in the style sheet at - https://maplibre.org/maplibre-style-spec/sources/ */ - MLNResourceKindTile, - /** Signed distance field glyphs for text rendering. These are the URLs specified in the style - in https://maplibre.org/maplibre-style-spec/root/#glyphs */ - MLNResourceKindGlyphs, - /** Image part of a sprite sheet. It is constructed of the prefix in - https://maplibre.org/maplibre-style-spec/root/#sprite and a PNG file extension. */ - MLNResourceKindSpriteImage, - /** JSON part of a sprite sheet. It is constructed of the prefix in - https://maplibre.org/maplibre-style-spec/root/#sprite and a JSON file extension. */ - MLNResourceKindSpriteJSON, - /** Image data for a georeferenced image source. **/ - MLNResourceKindImage, + /** Unknown type */ + MLNResourceKindUnknown, + /** Style sheet JSON file */ + MLNResourceKindStyle, + /** TileJSON file as specified in https://maplibre.org/maplibre-style-spec/root/#sources */ + MLNResourceKindSource, + /** A vector or raster tile as described in the style sheet at + https://maplibre.org/maplibre-style-spec/sources/ */ + MLNResourceKindTile, + /** Signed distance field glyphs for text rendering. These are the URLs specified in the style + in https://maplibre.org/maplibre-style-spec/root/#glyphs */ + MLNResourceKindGlyphs, + /** Image part of a sprite sheet. It is constructed of the prefix in + https://maplibre.org/maplibre-style-spec/root/#sprite and a PNG file extension. */ + MLNResourceKindSpriteImage, + /** JSON part of a sprite sheet. It is constructed of the prefix in + https://maplibre.org/maplibre-style-spec/root/#sprite and a JSON file extension. */ + MLNResourceKindSpriteJSON, + /** Image data for a georeferenced image source. **/ + MLNResourceKindImage, }; /** @@ -186,7 +189,7 @@ typedef NS_ENUM(NSUInteger, MLNResourceKind) { Raster Tile API pricing and are not included in the Maps SDK’s “unlimited” requests. See our pricing page for more information. - + #### Related examples TODO: Download an offline map, learn how to create and register an offline pack for a defined region. @@ -209,13 +212,13 @@ MLN_EXPORT add or remove custom parameters, or reroute certain requests to other servers or endpoints. */ -@property(nonatomic, weak, nullable) IBOutlet id delegate; +@property (nonatomic, weak, nullable) IBOutlet id delegate; // MARK: - Managing the Database of Offline Packs /** The file path at which offline packs and the ambient cache are stored. - + To customize this path, specify the [`MLNOfflineStorageDatabasePath`](../infoplist-keys.html#mglofflinestoragedatabasepath) key in Info.plist. @@ -224,7 +227,7 @@ MLN_EXPORT /** The file URL at which offline packs and the ambient cache are stored. - + To customize this path, specify the [`MLNOfflineStorageDatabasePath`](../infoplist-keys.html#mglofflinestoragedatabasepath) key in Info.plist. @@ -233,37 +236,39 @@ MLN_EXPORT /** Adds the offline packs located at the given file path to offline storage. - + The file must be a valid offline pack database bundled with the application or downloaded separately. - + The resulting packs are added or updated to the shared offline storage object’s `packs` property, then the `completion` block is executed. - + @param filePath A string representation of the file path. The file path must be writable as schema updates may be perfomed. @param completion The completion handler to call once the contents of the given file has been added to offline storage. This handler is executed asynchronously on the main queue. */ -- (void)addContentsOfFile:(NSString *)filePath withCompletionHandler:(nullable MLNBatchedOfflinePackAdditionCompletionHandler)completion; +- (void)addContentsOfFile:(NSString *)filePath + withCompletionHandler:(nullable MLNBatchedOfflinePackAdditionCompletionHandler)completion; /** Adds the offline packs located at the given URL to offline storage. - + The file must be a valid offline pack database bundled with the application or downloaded separately. - + The resulting packs are added or updated to the shared offline storage object’s `packs` property, then the `completion` block is executed. - + @param fileURL A file URL specifying the file to add. The URL should be a valid system path. The URL must be writable as schema updates may be performed. @param completion The completion handler to call once the contents of the given file has been added to offline storage. This handler is executed asynchronously on the main queue. */ -- (void)addContentsOfURL:(NSURL *)fileURL withCompletionHandler:(nullable MLNBatchedOfflinePackAdditionCompletionHandler)completion; +- (void)addContentsOfURL:(NSURL *)fileURL + withCompletionHandler:(nullable MLNBatchedOfflinePackAdditionCompletionHandler)completion; // MARK: - Managing Offline Packs @@ -303,7 +308,9 @@ MLN_EXPORT @param completion The completion handler to call once the pack has been added. This handler is executed asynchronously on the main queue. */ -- (void)addPackForRegion:(id )region withContext:(NSData *)context completionHandler:(nullable MLNOfflinePackAdditionCompletionHandler)completion; +- (void)addPackForRegion:(id)region + withContext:(NSData *)context + completionHandler:(nullable MLNOfflinePackAdditionCompletionHandler)completion; /** Unregisters the given offline pack and allows resources that are no longer @@ -330,23 +337,25 @@ MLN_EXPORT @param completion The completion handler to call once the pack has been removed. This handler is executed asynchronously on the main queue. */ -- (void)removePack:(MLNOfflinePack *)pack withCompletionHandler:(nullable MLNOfflinePackRemovalCompletionHandler)completion; +- (void)removePack:(MLNOfflinePack *)pack + withCompletionHandler:(nullable MLNOfflinePackRemovalCompletionHandler)completion; /** Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated. - + This is more efficient than deleting the offline pack and downloading it again. If the data stored locally matches that on the server, new data will not be downloaded. - + @param pack The offline pack to be invalidated. @param completion The completion handler to call once the pack has been removed. This handler is executed asynchronously on the main queue. */ -- (void)invalidatePack:(MLNOfflinePack *)pack withCompletionHandler:(void (^)(NSError * _Nullable))completion; +- (void)invalidatePack:(MLNOfflinePack *)pack + withCompletionHandler:(void (^)(NSError *_Nullable))completion; /** Forcibly, asynchronously reloads the `packs` property. At some point after this method is called, the pointer values of the `MLNOfflinePack` objects in the @@ -390,34 +399,35 @@ MLN_EXPORT size is 50 MB. To disable ambient caching, set the maximum ambient cache size to `0`. Setting the maximum ambient cache size does not impact the maximum size of offline packs. - + This method does not limit the space available to offline packs, and data in offline packs does not count towards this limit. If you set the maximum ambient cache size to 30 MB then download 20 MB of offline packs, 30 MB will remain available for the ambient cache. - + This method should be called before the map and map style have been loaded. - + This method is potentially expensive, as the database will trim cached data in order to prevent the ambient cache from being larger than the specified amount. - + @param cacheSize The maximum size in bytes for the ambient cache. @param completion The completion handler to call once the maximum ambient cache size has been set. This handler is executed synchronously on the main queue. */ -- (void)setMaximumAmbientCacheSize:(NSUInteger)cacheSize withCompletionHandler:(void (^)(NSError *_Nullable error))completion; +- (void)setMaximumAmbientCacheSize:(NSUInteger)cacheSize + withCompletionHandler:(void (^)(NSError *_Nullable error))completion; /** Invalidates the ambient cache. This method checks that the tiles in the ambient cache match those from the server. If the local tiles do not match those on the server, they are re-downloaded. - + This is recommended over clearing the cache or resetting the database because valid local tiles will not be downloaded again. - + Resources shared with offline packs will not be affected by this method. - + @param completion The completion handler to call once the ambient cache has been revalidated. This handler is executed asynchronously on the main queue. */ @@ -426,7 +436,7 @@ MLN_EXPORT /** Clears the ambient cache by deleting resources. This method does not affect resources shared with offline regions. - + @param completion The completion handler to call once resources from the ambient cache have been cleared. This handler is executed asynchronously on the main queue. @@ -436,9 +446,9 @@ MLN_EXPORT /** Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it. - + You typically do not need to call this method. - + @param completion The completion handler to call once the pack has database has been reset. This handler is executed asynchronously on the main queue. */ @@ -446,16 +456,17 @@ MLN_EXPORT /** Inserts the provided resource into the ambient cache. - + This method mimics the caching that would take place if the equivalent resource were requested in the process of map rendering. Use this method to pre-warm the cache with resources you know will be requested. - + This method is asynchronous; the data may not be immediately available for in-progress requests, though subsequent requests should have access to the cached data. - To find out when the resource is ready to retrieve from the cache, use the `-preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:completionHandler:` + To find out when the resource is ready to retrieve from the cache, use the + `-preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:completionHandler:` method. @param data Response data to store for this resource. The data is expected to @@ -467,9 +478,22 @@ MLN_EXPORT @param mustRevalidate A Boolean value indicating whether the data is still usable past the expiration date. */ -- (void)preloadData:(NSData *)data forURL:(NSURL *)url modificationDate:(nullable NSDate *)modified expirationDate:(nullable NSDate *)expires eTag:(nullable NSString *)eTag mustRevalidate:(BOOL)mustRevalidate NS_SWIFT_NAME(preload(_:for:modifiedOn:expiresOn:eTag:mustRevalidate:)); +- (void)preloadData:(NSData *)data + forURL:(NSURL *)url + modificationDate:(nullable NSDate *)modified + expirationDate:(nullable NSDate *)expires + eTag:(nullable NSString *)eTag + mustRevalidate:(BOOL)mustRevalidate + NS_SWIFT_NAME(preload(_:for:modifiedOn:expiresOn:eTag:mustRevalidate:)); -- (void)putResourceWithUrl:(NSURL *)url data:(NSData *)data modified:(nullable NSDate *)modified expires:(nullable NSDate *)expires etag:(nullable NSString *)etag mustRevalidate:(BOOL)mustRevalidate __attribute__((deprecated("", "-preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:"))); +- (void)putResourceWithUrl:(NSURL *)url + data:(NSData *)data + modified:(nullable NSDate *)modified + expires:(nullable NSDate *)expires + etag:(nullable NSString *)etag + mustRevalidate:(BOOL)mustRevalidate + __attribute__((deprecated( + "", "-preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:"))); /** Inserts the provided resource into the ambient cache, calling a completion @@ -493,7 +517,12 @@ MLN_EXPORT @param completion The completion handler to call once the data has been preloaded. This handler is executed asynchronously on the main queue. */ -- (void)preloadData:(NSData *)data forURL:(NSURL *)url modificationDate:(nullable NSDate *)modified expirationDate:(nullable NSDate *)expires eTag:(nullable NSString *)eTag mustRevalidate:(BOOL)mustRevalidate +- (void)preloadData:(NSData *)data + forURL:(NSURL *)url + modificationDate:(nullable NSDate *)modified + expirationDate:(nullable NSDate *)expires + eTag:(nullable NSString *)eTag + mustRevalidate:(BOOL)mustRevalidate completionHandler:(nullable MLNOfflinePreloadDataCompletionHandler)completion; @end diff --git a/platform/darwin/src/MLNOfflineStorage_Private.h b/platform/darwin/src/MLNOfflineStorage_Private.h index 757da59a5..dc020e16d 100644 --- a/platform/darwin/src/MLNOfflineStorage_Private.h +++ b/platform/darwin/src/MLNOfflineStorage_Private.h @@ -2,8 +2,8 @@ #import "MLNOfflinePack.h" -#include #include +#include #include "MLNSettings_Private.h" @@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic) std::shared_ptr mbglFileSource; -- (void)getPacksWithCompletionHandler:(void (^)(NSArray *packs, NSError * _Nullable error))completion; +- (void)getPacksWithCompletionHandler:(void (^)(NSArray *packs, + NSError *_Nullable error))completion; @end diff --git a/platform/darwin/src/MLNOverlay.h b/platform/darwin/src/MLNOverlay.h index 20e44f50a..aa4b03b24 100644 --- a/platform/darwin/src/MLNOverlay.h +++ b/platform/darwin/src/MLNOverlay.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNAnnotation.h" #import "MLNGeometry.h" @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN This property contains the smallest rectangle that completely encompasses the overlay. Implementers of this protocol must set this area when implementing their overlay class, and after setting it, you must not change it. - + If this overlay spans the antimeridian, its bounds may extend west of −180 degrees longitude or east of 180 degrees longitude. For example, an overlay covering the Pacific Ocean from Tokyo to San Francisco might have a bounds extending diff --git a/platform/darwin/src/MLNPointAnnotation.h b/platform/darwin/src/MLNPointAnnotation.h index 89bf060f5..a58158feb 100644 --- a/platform/darwin/src/MLNPointAnnotation.h +++ b/platform/darwin/src/MLNPointAnnotation.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" #import "MLNShape.h" @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN A point shape is known as a Point geometry in GeoJSON. - + #### Related examples TODO: Mark a place on the map with an annotation TODO: Mark a place on the map with an image diff --git a/platform/darwin/src/MLNPointCollection.h b/platform/darwin/src/MLNPointCollection.h index 2d86ca301..4fd68938a 100644 --- a/platform/darwin/src/MLNPointCollection.h +++ b/platform/darwin/src/MLNPointCollection.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" #import "MLNOverlay.h" @@ -40,7 +40,8 @@ MLN_EXPORT @param count The number of items in the `coords` array. @return A new point collection object. */ -+ (instancetype)pointCollectionWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count; ++ (instancetype)pointCollectionWithCoordinates:(const CLLocationCoordinate2D *)coords + count:(NSUInteger)count; /** The array of coordinates associated with the shape. */ @property (nonatomic, readonly) CLLocationCoordinate2D *coordinates NS_RETURNS_INNER_POINTER; diff --git a/platform/darwin/src/MLNPolygon.h b/platform/darwin/src/MLNPolygon.h index adee6f0ea..b0bbde441 100644 --- a/platform/darwin/src/MLNPolygon.h +++ b/platform/darwin/src/MLNPolygon.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" #import "MLNMultiPoint.h" @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN To make the polygon straddle the antimeridian, specify some longitudes less than −180 degrees or greater than 180 degrees. - + #### Related examples TODO: Add a polygon annotation, learn how to initialize an `MLNPolygon` object from an array of coordinates. @@ -72,7 +72,8 @@ MLN_EXPORT @param count The number of items in the `coords` array. @return A new polygon object. */ -+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count; ++ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords + count:(NSUInteger)count; /** Creates and returns an `MLNPolygon` object from the specified set of @@ -86,7 +87,9 @@ MLN_EXPORT is considered to have no interior polygons. @return A new polygon object. */ -+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count interiorPolygons:(nullable NSArray *)interiorPolygons; ++ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords + count:(NSUInteger)count + interiorPolygons:(nullable NSArray *)interiorPolygons; @end diff --git a/platform/darwin/src/MLNPolyline.h b/platform/darwin/src/MLNPolyline.h index bf42171d0..6377faea9 100644 --- a/platform/darwin/src/MLNPolyline.h +++ b/platform/darwin/src/MLNPolyline.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" #import "MLNMultiPoint.h" @@ -34,11 +34,11 @@ NS_ASSUME_NONNULL_BEGIN `MLNPolygon` object. To group multiple polylines together in one shape, use an `MLNMultiPolyline` or `MLNShapeCollection` object. - To make the polyline go across the antimeridian or international date line, + To make the polyline go across the antimeridian or international date line, specify some longitudes less than −180 degrees or greater than 180 degrees. For example, a polyline that stretches from Tokyo to San Francisco would have coordinates of (35.68476, -220.24257) and (37.78428, -122.41310). - + ```swift let coordinates = [ CLLocationCoordinate2D(latitude: 35.68476, longitude: -220.24257), @@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN A polyline is known as a LineString geometry in GeoJSON. - + #### Related examples - @@ -69,7 +69,8 @@ MLN_EXPORT @param count The number of items in the `coords` array. @return A new polyline object. */ -+ (instancetype)polylineWithCoordinates:(const CLLocationCoordinate2D *)coords count:(NSUInteger)count; ++ (instancetype)polylineWithCoordinates:(const CLLocationCoordinate2D *)coords + count:(NSUInteger)count; @end diff --git a/platform/darwin/src/MLNPolyline_Private.h b/platform/darwin/src/MLNPolyline_Private.h index b31f082bb..fc6d533e1 100644 --- a/platform/darwin/src/MLNPolyline_Private.h +++ b/platform/darwin/src/MLNPolyline_Private.h @@ -9,4 +9,3 @@ NS_ASSUME_NONNULL_BEGIN @end NS_ASSUME_NONNULL_END - diff --git a/platform/darwin/src/MLNRasterDEMSource.h b/platform/darwin/src/MLNRasterDEMSource.h index a8332f23f..a81aa5bc4 100644 --- a/platform/darwin/src/MLNRasterDEMSource.h +++ b/platform/darwin/src/MLNRasterDEMSource.h @@ -6,9 +6,9 @@ An `NSNumber` object containing an unsigned integer that specifies the encoding formula for raster-dem tilesets. The integer corresponds to one of the constants described in `MLNDEMEncoding`. - + The default value for this option is `MLNDEMEncodingMapbox`. - + This option cannot be represented in a TileJSON or style JSON file. It is used with the `MLNRasterDEMSource` class and is ignored when creating an `MLNRasterTileSource` or `MLNVectorTileSource` object. @@ -32,9 +32,11 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNTileSourceOption MLNTileSourceOptionDEMEnc `MLNRasterDEMSource` object that you can use to initialize new style layers. You can also add and remove sources dynamically using methods such as `-[MLNStyle addSource:]` and `-[MLNStyle sourceWithIdentifier:]`. - + Currently, raster DEM sources only support the format used by - Mapbox Terrain-RGB. + Mapbox + Terrain-RGB. ### Example diff --git a/platform/darwin/src/MLNRasterTileSource.h b/platform/darwin/src/MLNRasterTileSource.h index 93803f7c9..356a62dbc 100644 --- a/platform/darwin/src/MLNRasterTileSource.h +++ b/platform/darwin/src/MLNRasterTileSource.h @@ -42,12 +42,13 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNTileSourceOption MLNTileSourceOptionTileSi ### Example ```swift - let source = MLNRasterTileSource(identifier: "clouds", tileURLTemplates: ["https://example.com/raster-tiles/{z}/{x}/{y}.png"], options: [ - .minimumZoomLevel: 9, + let source = MLNRasterTileSource(identifier: "clouds", tileURLTemplates: + ["https://example.com/raster-tiles/{z}/{x}/{y}.png"], options: [ .minimumZoomLevel: 9, .maximumZoomLevel: 16, .tileSize: 512, .attributionInfos: [ - MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) + MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: + "https://mapbox.com")) ] ]) mapView.style?.addSource(source) @@ -85,7 +86,8 @@ MLN_EXPORT source’s contents and other metadata. @return An initialized raster tile source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL; +- (instancetype)initWithIdentifier:(NSString *)identifier + configurationURL:(NSURL *)configurationURL; /** Returns a raster tile source initialized with an identifier, configuration URL, @@ -107,7 +109,9 @@ MLN_EXPORT documentation for details. @return An initialized raster tile source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL tileSize:(CGFloat)tileSize NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + configurationURL:(NSURL *)configurationURL + tileSize:(CGFloat)tileSize NS_DESIGNATED_INITIALIZER; /** Returns a raster tile source initialized an identifier, tile URL templates, and @@ -129,7 +133,10 @@ MLN_EXPORT the default values. @return An initialized tile source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NSArray *)tileURLTemplates options:(nullable NSDictionary *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + tileURLTemplates:(NSArray *)tileURLTemplates + options:(nullable NSDictionary *)options + NS_DESIGNATED_INITIALIZER; @end diff --git a/platform/darwin/src/MLNRasterTileSource_Private.h b/platform/darwin/src/MLNRasterTileSource_Private.h index d95bc73ee..098c7b1ab 100644 --- a/platform/darwin/src/MLNRasterTileSource_Private.h +++ b/platform/darwin/src/MLNRasterTileSource_Private.h @@ -1,14 +1,14 @@ #import "MLNRasterTileSource.h" -#include #include +#include namespace mbgl { - class Tileset; - namespace style { - class RasterSource; - } +class Tileset; +namespace style { +class RasterSource; } +} // namespace mbgl NS_ASSUME_NONNULL_BEGIN @@ -16,7 +16,10 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, nullable) mbgl::style::RasterSource *rawSource; -- (std::unique_ptr)pendingSourceWithIdentifier:(NSString *)identifier urlOrTileset:(mbgl::variant)urlOrTileset tileSize:(uint16_t)tileSize; +- (std::unique_ptr) + pendingSourceWithIdentifier:(NSString *)identifier + urlOrTileset:(mbgl::variant)urlOrTileset + tileSize:(uint16_t)tileSize; @end diff --git a/platform/darwin/src/MLNReachability.h b/platform/darwin/src/MLNReachability.h index bfcf78059..d990ea68b 100644 --- a/platform/darwin/src/MLNReachability.h +++ b/platform/darwin/src/MLNReachability.h @@ -28,66 +28,65 @@ #import #import - /** * Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X. * * @see http://nshipster.com/ns_enum-ns_options/ **/ #ifndef NS_ENUM -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#define NS_ENUM(_type, _name) \ + enum _name : _type _name; \ + enum _name : _type #endif extern NSString *const kMLNReachabilityChangedNotification; typedef NS_ENUM(NSInteger, NetworkStatus) { - // Apple NetworkStatus Compatible Names. - NotReachable = 0, - ReachableViaWiFi = 2, - ReachableViaWWAN = 1 + // Apple NetworkStatus Compatible Names. + NotReachable = 0, + ReachableViaWiFi = 2, + ReachableViaWWAN = 1 }; @class MLNReachability; -typedef void (^NetworkReachable)(MLNReachability * reachability); -typedef void (^NetworkUnreachable)(MLNReachability * reachability); - +typedef void (^NetworkReachable)(MLNReachability *reachability); +typedef void (^NetworkUnreachable)(MLNReachability *reachability); @interface MLNReachability : NSObject -@property (nonatomic, copy) NetworkReachable reachableBlock; -@property (nonatomic, copy) NetworkUnreachable unreachableBlock; +@property (nonatomic, copy) NetworkReachable reachableBlock; +@property (nonatomic, copy) NetworkUnreachable unreachableBlock; @property (nonatomic, assign) BOOL reachableOnWWAN; - -+(instancetype)reachabilityWithHostname:(NSString*)hostname; ++ (instancetype)reachabilityWithHostname:(NSString *)hostname; // This is identical to the function above, but is here to maintain // compatibility with Apples original code. (see .m) -+(instancetype)reachabilityWithHostName:(NSString*)hostname; -+(instancetype)reachabilityForInternetConnection; -+(instancetype)reachabilityWithAddress:(void *)hostAddress; -+(instancetype)reachabilityForLocalWiFi; ++ (instancetype)reachabilityWithHostName:(NSString *)hostname; ++ (instancetype)reachabilityForInternetConnection; ++ (instancetype)reachabilityWithAddress:(void *)hostAddress; ++ (instancetype)reachabilityForLocalWiFi; --(BOOL)startNotifier; --(void)stopNotifier; +- (BOOL)startNotifier; +- (void)stopNotifier; --(BOOL)isReachable; --(BOOL)isReachableViaWWAN; --(BOOL)isReachableViaWiFi; +- (BOOL)isReachable; +- (BOOL)isReachableViaWWAN; +- (BOOL)isReachableViaWiFi; // WWAN may be available, but not active until a connection has been established. // WiFi may require a connection for VPN on Demand. --(BOOL)isConnectionRequired; // Identical DDG variant. --(BOOL)connectionRequired; // Apple's routine. +- (BOOL)isConnectionRequired; // Identical DDG variant. +- (BOOL)connectionRequired; // Apple's routine. // Dynamic, on demand connection? --(BOOL)isConnectionOnDemand; +- (BOOL)isConnectionOnDemand; // Is user intervention required? --(BOOL)isInterventionRequired; +- (BOOL)isInterventionRequired; --(NetworkStatus)currentReachabilityStatus; --(SCNetworkReachabilityFlags)reachabilityFlags; --(NSString*)currentReachabilityString; --(NSString*)currentReachabilityFlags; +- (NetworkStatus)currentReachabilityStatus; +- (SCNetworkReachabilityFlags)reachabilityFlags; +- (NSString *)currentReachabilityString; +- (NSString *)currentReachabilityFlags; @end diff --git a/platform/darwin/src/MLNRendererConfiguration.h b/platform/darwin/src/MLNRendererConfiguration.h index 5dd78a5aa..3bda166ab 100644 --- a/platform/darwin/src/MLNRendererConfiguration.h +++ b/platform/darwin/src/MLNRendererConfiguration.h @@ -1,5 +1,5 @@ -#import "MLNFoundation.h" #import +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN @@ -19,31 +19,32 @@ MLN_EXPORT @property (nonatomic, readonly) const float scaleFactor; /** The name of the font family to use for client-side text rendering of CJK ideographs. - + Set MLNIdeographicFontFamilyName in your containing application's Info.plist to font family name(s) that will be available at run time, such as “PingFang TC” or “Marker Felt”. This plist key accepts: - + - A string value of a single font family name. - + - An array of font family names. Fonts will be used in the defined order, eventually falling back to default system font if none are available. - + - A boolean value NO to disable client-side rendering of CJK glyphs — remote fonts specified in your style will be used instead. */ @property (nonatomic, readonly, nullable) NSString *localFontFamilyName; -- (nullable NSString *)localFontFamilyNameWithInfoDictionaryObject:(nullable id)infoDictionaryObject; +- (nullable NSString *)localFontFamilyNameWithInfoDictionaryObject: + (nullable id)infoDictionaryObject; /** A Boolean value indicating whether symbol layers may enable per-source symbol collision detection. - + Set `MLNCollisionBehaviorPre4_0` in your containing app's Info.plist or by using `[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:@"MLNCollisionBehaviorPre4_0"]`. If both are set, the value from `NSUserDefaults` takes priority. - + Setting this property to `YES` in the plist results in symbol layers only running collision detection against other symbol layers that are part of the same source. */ diff --git a/platform/darwin/src/MLNRendererFrontend.h b/platform/darwin/src/MLNRendererFrontend.h index 001c7aff8..401fdd312 100644 --- a/platform/darwin/src/MLNRendererFrontend.h +++ b/platform/darwin/src/MLNRendererFrontend.h @@ -1,73 +1,67 @@ #include +#include #include #include -#include #include /** The RenderFrontend is passed to the Map to facilitate rendering in a platform dependent way. */ -class MLNRenderFrontend : public mbgl::RendererFrontend -{ -public: - MLNRenderFrontend(std::unique_ptr renderer_, MLNMapView* nativeView_, mbgl::gfx::RendererBackend& mbglBackend_, bool async = false) - : renderer(std::move(renderer_)) - , nativeView(nativeView_) - , mbglBackend(mbglBackend_) { - if (async) { - asyncInvalidate.emplace([&]() { - [nativeView setNeedsRerender]; - }); - } +class MLNRenderFrontend : public mbgl::RendererFrontend { + public: + MLNRenderFrontend(std::unique_ptr renderer_, MLNMapView* nativeView_, + mbgl::gfx::RendererBackend& mbglBackend_, bool async = false) + : renderer(std::move(renderer_)), nativeView(nativeView_), mbglBackend(mbglBackend_) { + if (async) { + asyncInvalidate.emplace([&]() { [nativeView setNeedsRerender]; }); } - - void reset() override { - if (renderer) { - renderer.reset(); - } + } + + void reset() override { + if (renderer) { + renderer.reset(); } - - void update(std::shared_ptr updateParameters_) override { - updateParameters = std::move(updateParameters_); - if (asyncInvalidate) { - asyncInvalidate->send(); - } else { - [nativeView setNeedsRerender]; - } + } + + void update(std::shared_ptr updateParameters_) override { + updateParameters = std::move(updateParameters_); + if (asyncInvalidate) { + asyncInvalidate->send(); + } else { + [nativeView setNeedsRerender]; } - - void setObserver(mbgl::RendererObserver& observer) override { - if (!renderer) return; - renderer->setObserver(&observer); - } - - void render() { - if (!renderer || !updateParameters) return; - - mbgl::gfx::BackendScope guard { mbglBackend, mbgl::gfx::BackendScope::ScopeType::Implicit }; - - // onStyleImageMissing might be called during a render. The user implemented method - // could trigger a call to MLNRenderFrontend#update which overwrites `updateParameters`. - // Copy the shared pointer here so that the parameters aren't destroyed while `render(...)` is - // still using them. - auto updateParameters_ = updateParameters; - renderer->render(updateParameters_); - } - - mbgl::Renderer* getRenderer() { - return renderer.get(); - } - - void reduceMemoryUse() { - if (!renderer) return; - renderer->reduceMemoryUse(); - } - -private: - std::unique_ptr renderer; - __weak MLNMapView *nativeView = nullptr; - mbgl::gfx::RendererBackend& mbglBackend; - std::shared_ptr updateParameters; - std::optional asyncInvalidate; + } + + void setObserver(mbgl::RendererObserver& observer) override { + if (!renderer) return; + renderer->setObserver(&observer); + } + + void render() { + if (!renderer || !updateParameters) return; + + mbgl::gfx::BackendScope guard{mbglBackend, mbgl::gfx::BackendScope::ScopeType::Implicit}; + + // onStyleImageMissing might be called during a render. The user implemented method + // could trigger a call to MLNRenderFrontend#update which overwrites `updateParameters`. + // Copy the shared pointer here so that the parameters aren't destroyed while `render(...)` is + // still using them. + auto updateParameters_ = updateParameters; + renderer->render(updateParameters_); + } + + mbgl::Renderer* getRenderer() { return renderer.get(); } + + void reduceMemoryUse() { + if (!renderer) return; + renderer->reduceMemoryUse(); + } + + private: + std::unique_ptr renderer; + __weak MLNMapView* nativeView = nullptr; + mbgl::gfx::RendererBackend& mbglBackend; + std::shared_ptr updateParameters; + std::optional asyncInvalidate; }; diff --git a/platform/darwin/src/MLNSettings.h b/platform/darwin/src/MLNSettings.h index dc11e9719..2f9b01d09 100644 --- a/platform/darwin/src/MLNSettings.h +++ b/platform/darwin/src/MLNSettings.h @@ -9,18 +9,18 @@ NS_ASSUME_NONNULL_BEGIN Well-known tile servers */ typedef NS_ENUM(NSUInteger, MLNWellKnownTileServer) { - /** - Maptiler - */ - MLNMapTiler, - /** - MapLibre - */ - MLNMapLibre, - /** - Mapbox - */ - MLNMapbox + /** + Maptiler + */ + MLNMapTiler, + /** + MapLibre + */ + MLNMapLibre, + /** + Mapbox + */ + MLNMapbox }; /** @@ -50,7 +50,7 @@ MLN_EXPORT and the type `String`. Alternatively, you may call this method from your application delegate’s `-applicationDidFinishLaunching:` method. */ -@property (class, copy, nullable) NSString *apiKey; +@property (class, copy, nullable) NSString* apiKey; /** Instructs the SDk to use the give tile server diff --git a/platform/darwin/src/MLNSettings_Private.h b/platform/darwin/src/MLNSettings_Private.h index 501a4607b..591fade17 100644 --- a/platform/darwin/src/MLNSettings_Private.h +++ b/platform/darwin/src/MLNSettings_Private.h @@ -1,6 +1,6 @@ -#import "MLNSettings.h" -#import #import +#import +#import "MLNSettings.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/darwin/src/MLNShape.h b/platform/darwin/src/MLNShape.h index afc122f80..151abb176 100644 --- a/platform/darwin/src/MLNShape.h +++ b/platform/darwin/src/MLNShape.h @@ -1,7 +1,7 @@ #import -#import "MLNFoundation.h" #import "MLNAnnotation.h" +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN shapes collectively using a concrete instance of `MLNVectorStyleLayer`. Alternatively, you can add some kinds of shapes directly to a map view as annotations or overlays. - + You can filter the features in a `MLNVectorStyleLayer` or vary their layout or paint attributes based on the features’ geographies. Pass an `MLNShape` into an `NSPredicate` with the format `SELF IN %@` or `%@ CONTAINS SELF` and set the @@ -56,7 +56,8 @@ MLN_EXPORT ```swift let url = mainBundle.url(forResource: "amsterdam", withExtension: "geojson")! let data = try! Data(contentsOf: url) - let feature = try! MLNShape(data: data, encoding: String.Encoding.utf8.rawValue) as! MLNShapeCollectionFeature + let feature = try! MLNShape(data: data, encoding: String.Encoding.utf8.rawValue) as! + MLNShapeCollectionFeature ``` @param data String data containing GeoJSON source code. @@ -67,7 +68,9 @@ MLN_EXPORT not be parsed as valid GeoJSON source code. If `nil`, `outError` contains an `NSError` object describing the problem. */ -+ (nullable MLNShape *)shapeWithData:(NSData *)data encoding:(NSStringEncoding)encoding error:(NSError * _Nullable *)outError; ++ (nullable MLNShape *)shapeWithData:(NSData *)data + encoding:(NSStringEncoding)encoding + error:(NSError *_Nullable *)outError; // MARK: Accessing the Shape Attributes diff --git a/platform/darwin/src/MLNShapeOfflineRegion.h b/platform/darwin/src/MLNShapeOfflineRegion.h index d2f789157..7f20fc8e9 100644 --- a/platform/darwin/src/MLNShapeOfflineRegion.h +++ b/platform/darwin/src/MLNShapeOfflineRegion.h @@ -9,7 +9,7 @@ NS_ASSUME_NONNULL_BEGIN /** An offline region defined by a style URL, geographic shape, and range of zoom levels. - + ### Example ```swift var coordinates = [ @@ -17,13 +17,13 @@ NS_ASSUME_NONNULL_BEGIN CLLocationCoordinate2D(latitude: 45.534611, longitude: -122.708873), CLLocationCoordinate2D(latitude: 45.530883, longitude: -122.678833) ] - + let triangle = MLNPolygon(coordinates: &coordinates, count: UInt(coordinates.count)) - let region = MLNShapeOfflineRegion(styleURL: MLNStyle.lightStyleURL, shape: triangle, fromZoomLevel: 11, toZoomLevel: 14) - let context = "Triangle Region".data(using: .utf8) + let region = MLNShapeOfflineRegion(styleURL: MLNStyle.lightStyleURL, shape: triangle, + fromZoomLevel: 11, toZoomLevel: 14) let context = "Triangle Region".data(using: .utf8) MLNOfflineStorage.shared.addPack(for: region, withContext: context!) ``` - + This class requires fewer resources than MLNTilePyramidOfflineRegion for irregularly shaped regions. */ @@ -79,7 +79,10 @@ MLN_EXPORT level, the download covers zoom levels up to the tile source’s maximum zoom level. */ -- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL shape:(MLNShape *)shape fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL + shape:(MLNShape *)shape + fromZoomLevel:(double)minimumZoomLevel + toZoomLevel:(double)maximumZoomLevel NS_DESIGNATED_INITIALIZER; @end diff --git a/platform/darwin/src/MLNShapeOfflineRegion_Private.h b/platform/darwin/src/MLNShapeOfflineRegion_Private.h index 9ccf94234..a70bb46ec 100644 --- a/platform/darwin/src/MLNShapeOfflineRegion_Private.h +++ b/platform/darwin/src/MLNShapeOfflineRegion_Private.h @@ -15,7 +15,8 @@ NS_ASSUME_NONNULL_BEGIN @param definition A reference to an offline region definition backing the offline region. */ -- (instancetype)initWithOfflineRegionDefinition:(const mbgl::OfflineGeometryRegionDefinition &)definition; +- (instancetype)initWithOfflineRegionDefinition: + (const mbgl::OfflineGeometryRegionDefinition &)definition; @end diff --git a/platform/darwin/src/MLNShapeSource.h b/platform/darwin/src/MLNShapeSource.h index 0a9f24ed4..595a6c901 100644 --- a/platform/darwin/src/MLNShapeSource.h +++ b/platform/darwin/src/MLNShapeSource.h @@ -1,6 +1,6 @@ #import "MLNFoundation.h" -#import "MLNTypes.h" #import "MLNSource.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -18,11 +18,12 @@ typedef NSString *MLNShapeSourceOption NS_STRING_ENUM; An `NSNumber` object containing a Boolean enabling or disabling clustering. If the `shape` property contains point shapes, setting this option to `YES` clusters the points by radius into groups. The default value is `NO`. - + This option corresponds to the - cluster + cluster source property in the MapLibre Style Spec. - + This option only affects point features within an `MLNShapeSource` object; it is ignored when creating an `MLNComputedShapeSource` object. @@ -37,7 +38,7 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionClus An `NSNumber` object containing an integer; specifies the radius of each cluster if clustering is enabled. A value of 512 produces a radius equal to the width of a tile. The default value is 50. - + This option only affects point features within an `MLNShapeSource` object; it is ignored when creating an `MLNComputedShapeSource` object. */ @@ -62,13 +63,14 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionClus let firstExpression = NSExpression(format: "sum:({$featureAccumulated, sumValue})") let secondExpression = NSExpression(forKeyPath: "magnitude") let clusterPropertiesDictionary = ["sumValue" : [firstExpression, secondExpression]] - + let options : [MLNShapeSourceOption : Any] = [.clustered : true, .clusterProperties: clusterPropertiesDictionary] ``` This option corresponds to the - clusterProperties + clusterProperties source property in the MapLibre Style Spec. This option only affects point features within an `MLNShapeSource` object; it @@ -80,22 +82,25 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionClus which to cluster points if clustering is enabled. Defaults to one zoom level less than the value of `MLNShapeSourceOptionMaximumZoomLevel` so that, at the maximum zoom level, the shapes are not clustered. - + This option corresponds to the - clusterMaxZoom + clusterMaxZoom source property in the MapLibre Style Spec. - + This option only affects point features within an `MLNShapeSource` object; it is ignored when creating an `MLNComputedShapeSource` object. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionMaximumZoomLevelForClustering; +FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption + MLNShapeSourceOptionMaximumZoomLevelForClustering; /** An `NSNumber` object containing an integer; specifies the minimum zoom level at which to create vector tiles. The default value is 0. This option corresponds to the - minzoom + minzoom source property in the MapLibre Style Spec. */ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionMinimumZoomLevel; @@ -104,9 +109,10 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionMini An `NSNumber` object containing an integer; specifies the maximum zoom level at which to create vector tiles. A greater value produces greater detail at high zoom levels. The default value is 18. - + This option corresponds to the - maxzoom + maxzoom source property in the MapLibre Style Spec. */ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionMaximumZoomLevel; @@ -116,7 +122,7 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionMaxi buffer on each side. A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself. Larger values produce fewer rendering artifacts near tile edges and slower performance. The default value is 128. - + This option corresponds to the buffer source property in the MapLibre Style Spec. @@ -127,21 +133,23 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionBuff An `NSNumber` object containing a double; specifies the Douglas-Peucker simplification tolerance. A greater value produces simpler geometries and improves performance. The default value is 0.375. - + This option corresponds to the - tolerance + tolerance source property in the MapLibre Style Spec. */ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionSimplificationTolerance; /** - An `NSNumber` object containing a Boolean enabling or disabling calculating line distance metrics. - - Set this property to `YES` in order for the `MLNLineStyleLayer.lineGradient` property to have its intended effect. - The default value is `NO`. - + An `NSNumber` object containing a Boolean enabling or disabling calculating line distance metrics. + + Set this property to `YES` in order for the `MLNLineStyleLayer.lineGradient` property to have its + intended effect. The default value is `NO`. + This option corresponds to the - lineMetrics + lineMetrics source property in the MapLibre Style Spec. */ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionLineDistanceMetrics; @@ -154,7 +162,7 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionLine `MLNStyle` object along with an `MLNVectorStyleLayer` object. The vector style layer defines the appearance of any content supplied by the shape source. You can update a shape source by setting its `shape` or `URL` property. - + `MLNShapeSource` is optimized for data sets that change dynamically and fit completely in memory. For large data sets that do not fit completely in memory, use the `MLNComputedShapeSource` or `MLNVectorTileSource` class. @@ -181,7 +189,7 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionLine let source = MLNShapeSource(identifier: "lines", features: [polyline], options: nil) mapView.style?.addSource(source) ``` - + #### Related examples TODO: Cluster point data TODO: Use images to cluster point data @@ -196,7 +204,7 @@ MLN_EXPORT /** Returns a shape source with an identifier, URL, and dictionary of options for the source. - + This class supports the following options: `MLNShapeSourceOptionClustered`, `MLNShapeSourceOptionClusterRadius`, `MLNShapeSourceOptionMaximumZoomLevelForClustering`, @@ -210,17 +218,20 @@ MLN_EXPORT current application’s resource bundle. @param options An `NSDictionary` of options for this source. @return An initialized shape source. - + #### Related examples TODO: Add live data, learn how to add live data to your map by updating the an `MLNShapeSource` object's `URL` property. */ -- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url options:(nullable NSDictionary *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + URL:(NSURL *)url + options:(nullable NSDictionary *)options + NS_DESIGNATED_INITIALIZER; /** Returns a shape source with an identifier, a shape, and dictionary of options for the source. - + This class supports the following options: `MLNShapeSourceOptionClustered`, `MLNShapeSourceOptionClusterRadius`, `MLNShapeSourceOptionMaximumZoomLevelForClustering`, @@ -243,17 +254,20 @@ MLN_EXPORT @param shape A concrete subclass of `MLNShape` @param options An `NSDictionary` of options for this source. @return An initialized shape source. - + #### Related examples TODO: Animate a line, learn how to animate line data by continously updating an `MLNShapeSource`'s `shape` attribute. */ -- (instancetype)initWithIdentifier:(NSString *)identifier shape:(nullable MLNShape *)shape options:(nullable NSDictionary *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + shape:(nullable MLNShape *)shape + options:(nullable NSDictionary *)options + NS_DESIGNATED_INITIALIZER; /** Returns a shape source with an identifier, an array of features, and a dictionary of options for the source. - + This class supports the following options: `MLNShapeSourceOptionClustered`, `MLNShapeSourceOptionClusterRadius`, `MLNShapeSourceOptionMaximumZoomLevelForClustering`, @@ -275,12 +289,14 @@ MLN_EXPORT @param options An `NSDictionary` of options for this source. @return An initialized shape source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier features:(NSArray *> *)features options:(nullable NSDictionary *)options; +- (instancetype)initWithIdentifier:(NSString *)identifier + features:(NSArray *> *)features + options:(nullable NSDictionary *)options; /** Returns a shape source with an identifier, an array of shapes, and a dictionary of options for the source. - + This class supports the following options: `MLNShapeSourceOptionClustered`, `MLNShapeSourceOptionClusterRadius`, `MLNShapeSourceOptionMaximumZoomLevelForClustering`, @@ -303,7 +319,9 @@ MLN_EXPORT @param options An `NSDictionary` of options for this source. @return An initialized shape source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier shapes:(NSArray *)shapes options:(nullable NSDictionary *)options; +- (instancetype)initWithIdentifier:(NSString *)identifier + shapes:(NSArray *)shapes + options:(nullable NSDictionary *)options; // MARK: Accessing a Source’s Content @@ -342,7 +360,7 @@ MLN_EXPORT the road that lie within the map tiles that the source has loaded, even if the road extends into other tiles. The portion of the road within each map tile is included individually. - + Returned features may not necessarily be visible to the user at the time they are loaded: the style may lack a layer that draws the features in question. To obtain only _visible_ features, use the @@ -356,32 +374,36 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features in the source that match the predicate. */ -- (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; +- (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; /** Returns an array of map features that are the leaves of the specified cluster. ("Leaves" are the original points that belong to the cluster.) - + This method supports pagination; you supply an offset (number of features to skip) and a maximum number of features to return. - - @param cluster An object of type `MLNPointFeatureCluster` (that conforms to the `MLNCluster` protocol). + + @param cluster An object of type `MLNPointFeatureCluster` (that conforms to the `MLNCluster` + protocol). @param offset Number of features to skip. @param limit The maximum number of features to return - + @return An array of objects that conform to the `MLNFeature` protocol. */ -- (NSArray> *)leavesOfCluster:(MLNPointFeatureCluster *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; +- (NSArray> *)leavesOfCluster:(MLNPointFeatureCluster *)cluster + offset:(NSUInteger)offset + limit:(NSUInteger)limit; /** Returns an array of map features that are the immediate children of the specified cluster *on the next zoom level*. The may include features that also conform to the `MLNCluster` protocol (currently only objects of type `MLNPointFeatureCluster`). - - @param cluster An object of type `MLNPointFeatureCluster` (that conforms to the `MLNCluster` protocol). - + + @param cluster An object of type `MLNPointFeatureCluster` (that conforms to the `MLNCluster` + protocol). + @return An array of objects that conform to the `MLNFeature` protocol. - + @note The returned array may contain the `cluster` that was passed in, if the next zoom level doesn't match the zoom level for expanding that cluster. See `-[MLNShapeSource zoomLevelForExpandingCluster:]`. @@ -390,9 +412,10 @@ MLN_EXPORT /** Returns the zoom level at which the given cluster expands. - - @param cluster An object of type `MLNPointFeatureCluster` (that conforms to the `MLNCluster` protocol). - + + @param cluster An object of type `MLNPointFeatureCluster` (that conforms to the `MLNCluster` + protocol). + @return Zoom level. This should be >= 0; any negative return value should be considered an error. */ diff --git a/platform/darwin/src/MLNShapeSource_Private.h b/platform/darwin/src/MLNShapeSource_Private.h index c1c998013..8203a4fdd 100644 --- a/platform/darwin/src/MLNShapeSource_Private.h +++ b/platform/darwin/src/MLNShapeSource_Private.h @@ -1,17 +1,18 @@ +#include #import "MLNFoundation.h" #import "MLNShapeSource.h" -#include NS_ASSUME_NONNULL_BEGIN namespace mbgl { - namespace style { - struct GeoJSONOptions; - } +namespace style { +struct GeoJSONOptions; } +} // namespace mbgl MLN_EXPORT -mbgl::Immutable MLNGeoJSONOptionsFromDictionary(NSDictionary *options); +mbgl::Immutable MLNGeoJSONOptionsFromDictionary( + NSDictionary *options); @interface MLNShapeSource (Private) @@ -21,7 +22,7 @@ mbgl::Immutable MLNGeoJSONOptionsFromDictionary(NSD that the feature conforms to `MLNCluster`. This method is used for testing and should be considered experimental, likely to be removed or changed in future releases. - + @param feature An object that conforms to the `MLNFeature` protocol. @param indent Used during recursion. Specify 0. */ diff --git a/platform/darwin/src/MLNShape_Private.h b/platform/darwin/src/MLNShape_Private.h index 5036f3492..c5220104a 100644 --- a/platform/darwin/src/MLNShape_Private.h +++ b/platform/darwin/src/MLNShape_Private.h @@ -1,8 +1,8 @@ #import "MLNShape.h" +#import #import #import -#import bool operator==(const CLLocationCoordinate2D lhs, const CLLocationCoordinate2D rhs); diff --git a/platform/darwin/src/MLNSource_Private.h b/platform/darwin/src/MLNSource_Private.h index 33b78250c..d8006d611 100644 --- a/platform/darwin/src/MLNSource_Private.h +++ b/platform/darwin/src/MLNSource_Private.h @@ -2,38 +2,37 @@ #include - NS_ASSUME_NONNULL_BEGIN @protocol MLNStylable; namespace mbgl { - namespace style { - class Source; - } +namespace style { +class Source; } +} // namespace mbgl // A struct to be stored in the `peer` member of mbgl::style::Source, in order to implement // object identity. We don't store a MLNSource pointer directly because that doesn't // interoperate with ARC. The inner pointer is weak in order to avoid a reference cycle for // "pending" MLNSources, which have a strong owning pointer to the mbgl::style::Source. struct SourceWrapper { - __weak MLNSource *source; + __weak MLNSource *source; }; /** Assert that the style source is valid. - + This macro should be used at the beginning of any public-facing instance method of `MLNSource` and its subclasses. For private methods, an assertion is more appropriate. */ -#define MLNAssertStyleSourceIsValid() \ -do { \ - if (!self.rawSource) { \ - [NSException raise:MLNInvalidStyleSourceException \ - format:@"This source got invalidated after the style change"]; \ - } \ -} while (NO); +#define MLNAssertStyleSourceIsValid() \ + do { \ + if (!self.rawSource) { \ + [NSException raise:MLNInvalidStyleSourceException \ + format:@"This source got invalidated after the style change"]; \ + } \ + } while (NO); @class MLNMapView; @@ -43,7 +42,8 @@ do { \ Initializes and returns a source with a raw pointer to the backing store, associated with a style. */ -- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource stylable:(nullable id )stylable; +- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource + stylable:(nullable id)stylable; /** Initializes and returns a source with an owning pointer to the backing store, @@ -62,11 +62,11 @@ do { \ /** The stylable object whose style currently contains the source. - + If the source is not currently part of any stylable object’s style, this property is set to `nil`. */ -@property (nonatomic, readonly, weak) id stylable; +@property (nonatomic, readonly, weak) id stylable; /** Adds the mbgl source that this object represents to the mbgl map. @@ -77,7 +77,7 @@ do { \ is added back to the map via `-[MLNStyle addSource:]` and styled with a `MLNLayer`. */ -- (void)addToStylable:(id )mapView; +- (void)addToStylable:(id)mapView; /** Removes the mbgl source that this object represents from the mbgl map. @@ -85,7 +85,7 @@ do { \ to the `MLNSource` instance and the unique_ptr reference is valid again. It is safe to add the source back to the style after it is removed. */ -- (BOOL)removeFromStylable:(id )mapView error:(NSError * __nullable * __nullable)outError; +- (BOOL)removeFromStylable:(id)mapView error:(NSError *__nullable *__nullable)outError; @end diff --git a/platform/darwin/src/MLNStyle.h b/platform/darwin/src/MLNStyle.h index 3f2409487..056516232 100644 --- a/platform/darwin/src/MLNStyle.h +++ b/platform/darwin/src/MLNStyle.h @@ -5,9 +5,9 @@ #import "MLNTypes.h" +#import "MLNDefaultStyle.h" #import "MLNSettings.h" #import "MLNTileServerOptions.h" -#import "MLNDefaultStyle.h" @class MLNSource; @class MLNLight; @@ -43,23 +43,23 @@ MLN_EXPORT /** Returns list of predefined styles */ -+ (NSArray*) predefinedStyles; ++ (NSArray *)predefinedStyles; /** Returns default style */ -+ (MLNDefaultStyle*) defaultStyle; ++ (MLNDefaultStyle *)defaultStyle; /** Returns default style as NSURL */ -+ (nullable NSURL*) defaultStyleURL; ++ (nullable NSURL *)defaultStyleURL; /** Get predefined style by name - + @param withStyleName style name. */ -+ (nullable MLNDefaultStyle*) predefinedStyle:(NSString*)withStyleName; ++ (nullable MLNDefaultStyle *)predefinedStyle:(NSString *)withStyleName; // MARK: Accessing Metadata About the Style @@ -156,8 +156,7 @@ MLN_EXPORT @return `YES` if `source` was removed successfully. If `NO`, `outError` contains an `NSError` object describing the problem. */ -- (BOOL)removeSource:(MLNSource *)source error:(NSError * __nullable * __nullable)outError; - +- (BOOL)removeSource:(MLNSource *)source error:(NSError *__nullable *__nullable)outError; // MARK: Managing Style Layers @@ -335,7 +334,6 @@ MLN_EXPORT */ - (void)removeImageForName:(NSString *)name; - // MARK: Managing the Style's Light /** @@ -350,10 +348,10 @@ MLN_EXPORT This method automatically modifies the text property of any symbol style layer in the style whose source is the - Mapbox Streets source. - On iOS, the user can set the system’s preferred language in Settings, General - Settings, Language & Region. On macOS, the user can set the system’s preferred - language in the Language & Region pane of System Preferences. + Mapbox Streets + source. On iOS, the user can set the system’s preferred language in Settings, General Settings, + Language & Region. On macOS, the user can set the system’s preferred language in the Language & + Region pane of System Preferences. @param locale The locale into which labels should be localized. To use the system’s preferred language, if supported, specify `nil`. To use the local diff --git a/platform/darwin/src/MLNStyleLayer.h b/platform/darwin/src/MLNStyleLayer.h index 61881f4ee..6f3cfeccb 100644 --- a/platform/darwin/src/MLNStyleLayer.h +++ b/platform/darwin/src/MLNStyleLayer.h @@ -20,7 +20,7 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNInvalidStyleLayerExceptio `MLNForegroundStyleLayer` in order to use `MLNStyleLayer`'s properties and methods. You do not create instances of `MLNStyleLayer` directly, and do not create your own subclasses of this class. - + Do not add `MLNStyleLayer` objects to the `style` property of a `MLNMapView` before `-mapView:didFinishLoadingStyle:` is called. */ @@ -29,7 +29,8 @@ MLN_EXPORT // MARK: Initializing a Style Layer -- (instancetype)init __attribute__((unavailable("Use -init methods of concrete subclasses instead."))); +- (instancetype)init + __attribute__((unavailable("Use -init methods of concrete subclasses instead."))); // MARK: Identifying a Style Layer @@ -43,7 +44,7 @@ MLN_EXPORT /** Whether this layer is displayed. A value of `NO` hides the layer. - + #### Related examples TODO: Show and hide a layer, learn how to toggle an `MLNStyleLayer` object's visibility. @@ -51,12 +52,14 @@ MLN_EXPORT @property (nonatomic, assign, getter=isVisible) BOOL visible; /** - The maximum zoom level at which the layer gets parsed and appears. This value is a floating-point number. + The maximum zoom level at which the layer gets parsed and appears. This value is a floating-point + number. */ @property (nonatomic, assign) float maximumZoomLevel; /** - The minimum zoom level at which the layer gets parsed and appears. This value is a floating-point number. + The minimum zoom level at which the layer gets parsed and appears. This value is a floating-point + number. */ @property (nonatomic, assign) float minimumZoomLevel; diff --git a/platform/darwin/src/MLNStyleLayerManager.h b/platform/darwin/src/MLNStyleLayerManager.h index a11f0b0e1..0820175ad 100644 --- a/platform/darwin/src/MLNStyleLayerManager.h +++ b/platform/darwin/src/MLNStyleLayerManager.h @@ -43,5 +43,5 @@ private: std::vector> coreFactories; std::map typeToFactory; }; - -} // namespace mbgl + +} // namespace mbgl diff --git a/platform/darwin/src/MLNStyleLayer_Private.h b/platform/darwin/src/MLNStyleLayer_Private.h index 4c6068e96..8c0d53618 100644 --- a/platform/darwin/src/MLNStyleLayer_Private.h +++ b/platform/darwin/src/MLNStyleLayer_Private.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN // interoperate with ARC. The inner pointer is weak in order to avoid a reference cycle for // "pending" MLNStyleLayers, which have a strong owning pointer to the mbgl::style::Layer. struct LayerWrapper { - __weak MLNStyleLayer *layer; + __weak MLNStyleLayer *layer; }; /** @@ -22,19 +22,19 @@ struct LayerWrapper { This macro should be used at the beginning of any public-facing instance method of `MLNStyleLayer` and its subclasses. For private methods, an assertion is more appropriate. */ -#define MLNAssertStyleLayerIsValid() \ - do { \ - if (!self.rawLayer) { \ - [NSException raise:MLNInvalidStyleLayerException \ - format: \ - @"Either this layer got invalidated after the style change or " \ - @"-[MLNStyle removeLayer:] has been called " \ - @"with this instance but another style layer instance was added with the same identifer. It is an " \ - @"error to send any message to this layer since it cannot be recovered after removal due to the " \ - @"identifier collision. Use unique identifiers for all layer instances including layers of " \ - @"different types."]; \ - } \ - } while (NO); +#define MLNAssertStyleLayerIsValid() \ + do { \ + if (!self.rawLayer) { \ + [NSException raise:MLNInvalidStyleLayerException \ + format:@"Either this layer got invalidated after the style change or " \ + @"-[MLNStyle removeLayer:] has been called with this instance but " \ + @"another style layer instance was added with the same identifer. " \ + @"It is an error to send any message to this layer since it cannot " \ + @"be recovered after removal due to the identifier collision. " \ + @"Use unique identifiers for all layer instances including layers " \ + @"of different types."]; \ + } \ + } while (NO); @class MLNStyle; @@ -87,16 +87,16 @@ struct LayerWrapper { namespace mbgl { class LayerPeerFactory { -public: - virtual ~LayerPeerFactory() = default; - /** - Get the corresponding core layer factory. - */ - virtual LayerFactory* getCoreLayerFactory() = 0; - /** - Creates an MLNStyleLayer instance with a raw pointer to the backing store. - */ - virtual MLNStyleLayer* createPeer(style::Layer*) = 0; + public: + virtual ~LayerPeerFactory() = default; + /** + Get the corresponding core layer factory. + */ + virtual LayerFactory *getCoreLayerFactory() = 0; + /** + Creates an MLNStyleLayer instance with a raw pointer to the backing store. + */ + virtual MLNStyleLayer *createPeer(style::Layer *) = 0; }; } // namespace mbgl diff --git a/platform/darwin/src/MLNStyleValue.h b/platform/darwin/src/MLNStyleValue.h index 60376c143..79eb6ae53 100644 --- a/platform/darwin/src/MLNStyleValue.h +++ b/platform/darwin/src/MLNStyleValue.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" #import "MLNTypes.h" @@ -8,15 +8,24 @@ NS_ASSUME_NONNULL_BEGIN typedef NSString *MLNStyleFunctionOption NS_STRING_ENUM NS_UNAVAILABLE; -FOUNDATION_EXTERN MLN_EXPORT const MLNStyleFunctionOption MLNStyleFunctionOptionInterpolationBase __attribute__((unavailable("Use NSExpression instead, applying the mgl_interpolate:withCurveType:parameters:stops: function with a curve type of “exponential” and a non-nil parameter."))); +FOUNDATION_EXTERN MLN_EXPORT const MLNStyleFunctionOption MLNStyleFunctionOptionInterpolationBase + __attribute__((unavailable( + "Use NSExpression instead, applying the mgl_interpolate:withCurveType:parameters:stops: " + "function with a curve type of “exponential” and a non-nil parameter."))); -FOUNDATION_EXTERN MLN_EXPORT const MLNStyleFunctionOption MLNStyleFunctionOptionDefaultValue __attribute__((unavailable("Use +[NSExpression expressionForConditional:trueExpression:falseExpression:] instead."))); +FOUNDATION_EXTERN MLN_EXPORT const MLNStyleFunctionOption MLNStyleFunctionOptionDefaultValue + __attribute__((unavailable( + "Use +[NSExpression expressionForConditional:trueExpression:falseExpression:] instead."))); typedef NS_ENUM(NSUInteger, MLNInterpolationMode) { - MLNInterpolationModeExponential __attribute__((unavailable("Use NSExpression instead, applying the mgl_interpolate:withCurveType:parameters:stops: function with a curve type of “exponential”."))) = 0, - MLNInterpolationModeInterval __attribute__((unavailable("Use NSExpression instead, calling the mgl_step:from:stops: function."))), - MLNInterpolationModeCategorical __attribute__((unavailable("Use NSExpression instead."))), - MLNInterpolationModeIdentity __attribute__((unavailable("Use +[NSExpression expressionForKeyPath:] instead."))) + MLNInterpolationModeExponential __attribute__((unavailable( + "Use NSExpression instead, applying the mgl_interpolate:withCurveType:parameters:stops: " + "function with a curve type of “exponential”."))) = 0, + MLNInterpolationModeInterval __attribute__(( + unavailable("Use NSExpression instead, calling the mgl_step:from:stops: function."))), + MLNInterpolationModeCategorical __attribute__((unavailable("Use NSExpression instead."))), + MLNInterpolationModeIdentity + __attribute__((unavailable("Use +[NSExpression expressionForKeyPath:] instead."))) } __attribute__((unavailable("Use NSExpression instead."))); MLN_EXPORT __attribute__((unavailable("Use NSExpression instead."))) @@ -29,19 +38,27 @@ MLN_EXPORT __attribute__((unavailable("Use +[NSExpression expressionForConstantV @compatibility_alias MLNStyleConstantValue MLNConstantStyleValue; -MLN_EXPORT __attribute__((unavailable("Use NSExpression instead, calling the mgl_step:from:stops: or mgl_interpolate:withCurveType:parameters:stops: function."))) +MLN_EXPORT +__attribute__((unavailable("Use NSExpression instead, calling the mgl_step:from:stops: or " + "mgl_interpolate:withCurveType:parameters:stops: function."))) @interface MLNStyleFunction : MLNStyleValue @end -MLN_EXPORT __attribute__((unavailable("Use NSExpression instead, applying the mgl_step:from:stops: or mgl_interpolate:withCurveType:parameters:stops: function to the $zoomLevel variable."))) +MLN_EXPORT __attribute__((unavailable( + "Use NSExpression instead, applying the mgl_step:from:stops: or " + "mgl_interpolate:withCurveType:parameters:stops: function to the $zoomLevel variable."))) @interface MLNCameraStyleFunction : MLNStyleFunction @end -MLN_EXPORT __attribute__((unavailable("Use NSExpression instead, applying the mgl_step:from:stops: or mgl_interpolate:withCurveType:parameters:stops: function to a key path expression."))) +MLN_EXPORT __attribute__((unavailable( + "Use NSExpression instead, applying the mgl_step:from:stops: or " + "mgl_interpolate:withCurveType:parameters:stops: function to a key path expression."))) @interface MLNSourceStyleFunction : MLNStyleFunction @end -MLN_EXPORT __attribute__((unavailable("Use a NSExpression instead with nested mgl_step:from:stops: or mgl_interpolate:withCurveType:parameters:stops: function calls."))) +MLN_EXPORT +__attribute__((unavailable("Use a NSExpression instead with nested mgl_step:from:stops: or " + "mgl_interpolate:withCurveType:parameters:stops: function calls."))) @interface MLNCompositeStyleFunction : MLNStyleFunction @end diff --git a/platform/darwin/src/MLNStyleValue_Private.h b/platform/darwin/src/MLNStyleValue_Private.h index f389eaa35..e20ccb4fd 100644 --- a/platform/darwin/src/MLNStyleValue_Private.h +++ b/platform/darwin/src/MLNStyleValue_Private.h @@ -2,19 +2,19 @@ #import "MLNStyleValue.h" -#import "NSValue+MLNStyleAttributeAdditions.h" -#import "NSValue+MLNAdditions.h" -#import "NSExpression+MLNPrivateAdditions.h" -#import "NSDate+MLNAdditions.h" #import "MLNTypes.h" +#import "NSDate+MLNAdditions.h" +#import "NSExpression+MLNPrivateAdditions.h" +#import "NSValue+MLNAdditions.h" +#import "NSValue+MLNStyleAttributeAdditions.h" -#import "MLNConversion.h" #include -#include #include +#include #include #import #import +#import "MLNConversion.h" #import #include @@ -22,329 +22,323 @@ #include #if TARGET_OS_IPHONE - #import "UIColor+MLNAdditions.h" +#import "UIColor+MLNAdditions.h" #else - #import "NSColor+MLNAdditions.h" +#import "NSColor+MLNAdditions.h" #endif namespace mbgl { - namespace style { - namespace expression { - class Expression; - } - } +namespace style { +namespace expression { +class Expression; } +} // namespace style +} // namespace mbgl id MLNJSONObjectFromMBGLValue(const mbgl::Value &value); -NS_INLINE MLNTransition MLNTransitionFromOptions(const mbgl::style::TransitionOptions& options) { - MLNTransition transition; - transition.duration = MLNTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); - transition.delay = MLNTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); - - return transition; +NS_INLINE MLNTransition MLNTransitionFromOptions(const mbgl::style::TransitionOptions &options) { + MLNTransition transition; + transition.duration = + MLNTimeIntervalFromDuration(options.duration.value_or(mbgl::Duration::zero())); + transition.delay = MLNTimeIntervalFromDuration(options.delay.value_or(mbgl::Duration::zero())); + + return transition; } NS_INLINE mbgl::style::TransitionOptions MLNOptionsFromTransition(MLNTransition transition) { - mbgl::style::TransitionOptions options { { MLNDurationFromTimeInterval(transition.duration) }, { MLNDurationFromTimeInterval(transition.delay) } }; - return options; + mbgl::style::TransitionOptions options{{MLNDurationFromTimeInterval(transition.duration)}, + {MLNDurationFromTimeInterval(transition.delay)}}; + return options; } -std::unique_ptr MLNClusterPropertyFromNSExpression(NSExpression *expression); +std::unique_ptr MLNClusterPropertyFromNSExpression( + NSExpression *expression); id MLNJSONObjectFromMBGLExpression(const mbgl::style::expression::Expression &mbglExpression); -template +template class MLNStyleValueTransformer { -public: + public: + /// Convert an mbgl property value into an mgl style value + NSExpression *toExpression(const mbgl::style::PropertyValue &mbglValue) { + PropertyExpressionEvaluator evaluator; + return mbglValue.evaluate(evaluator); + } - /// Convert an mbgl property value into an mgl style value - NSExpression *toExpression(const mbgl::style::PropertyValue &mbglValue) { - PropertyExpressionEvaluator evaluator; - return mbglValue.evaluate(evaluator); + // Convert an mbgl heatmap color property value into an mgl style value + NSExpression *toExpression(const mbgl::style::ColorRampPropertyValue &mbglValue) { + if (mbglValue.isUndefined()) { + return nil; + } + return [NSExpression + expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())]; + } + + /** + Converts an NSExpression to an mbgl property value. + */ + template + typename std::enable_if_t::value, + MBGLValue> + toPropertyValue(NSExpression *expression, bool allowDataExpressions) { + if (!expression) { + return {}; } - // Convert an mbgl heatmap color property value into an mgl style value - NSExpression *toExpression(const mbgl::style::ColorRampPropertyValue &mbglValue) { - if (mbglValue.isUndefined()) { - return nil; - } - return [NSExpression expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())]; + if (expression.expressionType == NSConstantValueExpressionType) { + MBGLType mbglValue; + getMBGLValue(expression.constantValue, mbglValue); + return mbglValue; + } + if (expression.expressionType == NSAggregateExpressionType) { + MBGLType mbglValue; + getMBGLValue(expression.collection, mbglValue); + return mbglValue; } - /** - Converts an NSExpression to an mbgl property value. - */ - template - typename std::enable_if_t::value, - MBGLValue> toPropertyValue(NSExpression *expression, bool allowDataExpressions) { - if (!expression) { - return {}; - } + NSArray *jsonExpression = expression.mgl_jsonExpressionObject; - if (expression.expressionType == NSConstantValueExpressionType) { - MBGLType mbglValue; - getMBGLValue(expression.constantValue, mbglValue); - return mbglValue; - } - if (expression.expressionType == NSAggregateExpressionType) { - MBGLType mbglValue; - getMBGLValue(expression.collection, mbglValue); - return mbglValue; - } - - NSArray *jsonExpression = expression.mgl_jsonExpressionObject; - - mbgl::style::conversion::Error valueError; - auto value = mbgl::style::conversion::convert( - mbgl::style::conversion::makeConvertible(jsonExpression), valueError, allowDataExpressions, false); - if (!value) { - [NSException raise:NSInvalidArgumentException - format:@"Invalid property value: %@", @(valueError.message.c_str())]; - return {}; - } - - return *value; + mbgl::style::conversion::Error valueError; + auto value = mbgl::style::conversion::convert( + mbgl::style::conversion::makeConvertible(jsonExpression), valueError, allowDataExpressions, + false); + if (!value) { + [NSException raise:NSInvalidArgumentException + format:@"Invalid property value: %@", @(valueError.message.c_str())]; + return {}; } - /** - Converts an NSExpression to an mbgl property value. - */ - template - typename std::enable_if_t::value, - MBGLValue> toPropertyValue(NSExpression *expression) { - if (!expression) { - return {}; - } + return *value; + } - NSArray *jsonExpression = expression.mgl_jsonExpressionObject; - - mbgl::style::conversion::Error valueError; - auto value = mbgl::style::conversion::convert( - mbgl::style::conversion::makeConvertible(jsonExpression), valueError); - if (!value) { - [NSException raise:NSInvalidArgumentException - format:@"Invalid property value: %@", @(valueError.message.c_str())]; - return {}; - } - - return *value; + /** + Converts an NSExpression to an mbgl property value. + */ + template + typename std::enable_if_t::value, + MBGLValue> + toPropertyValue(NSExpression *expression) { + if (!expression) { + return {}; } -private: // Private utilities for converting from mgl to mbgl values + NSArray *jsonExpression = expression.mgl_jsonExpressionObject; - /** - As hack to allow converting enum => string values, we accept a second, dummy parameter in - the toRawStyleSpecValue() methods for converting 'atomic' (non-style-function) values. - This allows us to use `std::enable_if` to test (at compile time) whether or not MBGLType is an Enum. - */ - template ::value>::type, - typename MLNEnum = ObjCEnum, - class = typename std::enable_if::value>::type> - NSObject* toRawStyleSpecValue(NSObject *rawMLNValue, MBGLEnum &) { - if ([rawMLNValue isKindOfClass:[NSValue class]]) { - const auto rawNSValue = (NSValue *)rawMLNValue; - if (strcmp([rawNSValue objCType], @encode(CGVector)) == 0) { - // offset [x, y] - std::array mglValue = rawNSValue.mgl_offsetArrayValue; - return [NSArray arrayWithObjects:@(mglValue[0]), @(mglValue[1]), nil]; - } - } - // noop pass-through plain NSObject-based items - return rawMLNValue; + mbgl::style::conversion::Error valueError; + auto value = mbgl::style::conversion::convert( + mbgl::style::conversion::makeConvertible(jsonExpression), valueError); + if (!value) { + [NSException raise:NSInvalidArgumentException + format:@"Invalid property value: %@", @(valueError.message.c_str())]; + return {}; } - template ::value>::type, - typename MLNEnum = ObjCEnum, - class = typename std::enable_if::value>::type> - NSString* toRawStyleSpecValue(ObjCType rawValue, MBGLEnum &) { - MLNEnum mglEnum; - [rawValue getValue:&mglEnum]; - return @(mbgl::Enum::toString(mglEnum)); + return *value; + } + + private: // Private utilities for converting from mgl to mbgl values + /** + As hack to allow converting enum => string values, we accept a second, dummy parameter in + the toRawStyleSpecValue() methods for converting 'atomic' (non-style-function) values. + This allows us to use `std::enable_if` to test (at compile time) whether or not MBGLType is an + Enum. + */ + template ::value>::type, + typename MLNEnum = ObjCEnum, + class = typename std::enable_if::value>::type> + NSObject *toRawStyleSpecValue(NSObject *rawMLNValue, MBGLEnum &) { + if ([rawMLNValue isKindOfClass:[NSValue class]]) { + const auto rawNSValue = (NSValue *)rawMLNValue; + if (strcmp([rawNSValue objCType], @encode(CGVector)) == 0) { + // offset [x, y] + std::array mglValue = rawNSValue.mgl_offsetArrayValue; + return [NSArray arrayWithObjects:@(mglValue[0]), @(mglValue[1]), nil]; + } + } + // noop pass-through plain NSObject-based items + return rawMLNValue; + } + + template ::value>::type, + typename MLNEnum = ObjCEnum, + class = typename std::enable_if::value>::type> + NSString *toRawStyleSpecValue(ObjCType rawValue, MBGLEnum &) { + MLNEnum mglEnum; + [rawValue getValue:&mglEnum]; + return @(mbgl::Enum::toString(mglEnum)); + } + + NSObject *toRawStyleSpecValue(MLNColor *color, MBGLType &) { + return @(color.mgl_color.stringify().c_str()); + } + + // Bool + void getMBGLValue(NSNumber *rawValue, bool &mbglValue) { mbglValue = !!rawValue.boolValue; } + + // Float + void getMBGLValue(NSNumber *rawValue, float &mbglValue) { mbglValue = rawValue.floatValue; } + + // String + void getMBGLValue(NSString *rawValue, std::string &mbglValue) { mbglValue = rawValue.UTF8String; } + + // Formatted + void getMBGLValue(NSString *rawValue, mbgl::style::expression::Formatted &mbglValue) { + mbglValue = mbgl::style::expression::Formatted(rawValue.UTF8String); + } + + // Offsets + void getMBGLValue(id rawValue, std::array &mbglValue) { + if ([rawValue isKindOfClass:[NSValue class]]) { + mbglValue = [rawValue mgl_offsetArrayValue]; + } else if ([rawValue isKindOfClass:[NSArray class]]) { + NSArray *array = (NSArray *)rawValue; + getMBGLValue(array[0], mbglValue[0]); + getMBGLValue(array[1], mbglValue[1]); + } + } + + // Padding + void getMBGLValue(id rawValue, std::array &mbglValue) { + if ([rawValue isKindOfClass:[NSValue class]]) { + mbglValue = [rawValue mgl_paddingArrayValue]; + } else if ([rawValue isKindOfClass:[NSArray class]]) { + NSArray *array = (NSArray *)rawValue; + getMBGLValue(array[0], mbglValue[0]); + getMBGLValue(array[1], mbglValue[1]); + getMBGLValue(array[2], mbglValue[2]); + getMBGLValue(array[3], mbglValue[3]); + getMBGLValue(array[4], mbglValue[4]); + } + } + + // Color + void getMBGLValue(MLNColor *rawValue, mbgl::Color &mbglValue) { mbglValue = rawValue.mgl_color; } + + // Image + void getMBGLValue(NSString *rawValue, mbgl::style::expression::Image &mbglValue) { + mbglValue = mbgl::style::expression::Image(rawValue.UTF8String); + } + + // Array + void getMBGLValue(ObjCType rawValue, std::vector &mbglValue) { + mbglValue.reserve(rawValue.count); + for (id obj in rawValue) { + id constantObject = obj; + if ([obj isKindOfClass:[NSExpression class]] && + [obj expressionType] == NSConstantValueExpressionType) { + constantObject = [constantObject constantValue]; + } + MBGLElement mbglElement; + getMBGLValue(constantObject, mbglElement); + mbglValue.push_back(mbglElement); + } + } + + void getMBGLValue(NSValue *rawValue, mbgl::style::Position &mbglValue) { + auto spherical = rawValue.mgl_lightPositionArrayValue; + mbgl::style::Position position(spherical); + mbglValue = position; + } + + // Enumerations + template ::value>::type, + typename MLNEnum = ObjCEnum, + class = typename std::enable_if::value>::type> + void getMBGLValue(id rawValue, MBGLEnum &mbglValue) { + if ([rawValue isKindOfClass:[NSString class]]) { + mbglValue = *mbgl::Enum::toEnum([(NSString *)rawValue UTF8String]); + } else { + MLNEnum mglEnum; + [(NSValue *)rawValue getValue:&mglEnum]; + auto str = mbgl::Enum::toString(mglEnum); + mbglValue = *mbgl::Enum::toEnum(str); + } + } + + private: // Private utilities for converting from mbgl to mgl values + // Bool + static NSNumber *toMLNRawStyleValue(const bool mbglStopValue) { return @(mbglStopValue); } + + // Float + static NSNumber *toMLNRawStyleValue(const float mbglStopValue) { return @(mbglStopValue); } + + // Integer + static NSNumber *toMLNRawStyleValue(const int64_t mbglStopValue) { return @(mbglStopValue); } + + // String + static NSString *toMLNRawStyleValue(const std::string &mbglStopValue) { + return @(mbglStopValue.c_str()); + } + + // Formatted + static NSString *toMLNRawStyleValue(const mbgl::style::expression::Formatted &mbglStopValue) { + return @(mbglStopValue.toString().c_str()); + } + + // Offsets + static NSValue *toMLNRawStyleValue(const std::array &mbglStopValue) { + return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; + } + + // Padding + static NSValue *toMLNRawStyleValue(const std::array &mbglStopValue) { + return [NSValue mgl_valueWithPaddingArray:mbglStopValue]; + } + + // Color + static MLNColor *toMLNRawStyleValue(const mbgl::Color mbglStopValue) { + return [MLNColor mgl_colorWithColor:mbglStopValue]; + } + + // Image + static NSString *toMLNRawStyleValue(const mbgl::style::expression::Image &mbglImageValue) { + return @(mbglImageValue.id().c_str()); + } + + // Array + static NSArray *toMLNRawStyleValue( + const std::vector &mbglStopValue) { + NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()]; + for (const auto &mbglElement : mbglStopValue) { + [array addObject:[NSExpression expressionForConstantValue:toMLNRawStyleValue(mbglElement)]]; + } + return array; + } + + static NSValue *toMLNRawStyleValue(const mbgl::style::Position &mbglStopValue) { + std::array spherical = mbglStopValue.getSpherical(); + MLNSphericalPosition position = + MLNSphericalPositionMake(spherical[0], spherical[1], spherical[2]); + return [NSValue valueWithMLNSphericalPosition:position]; + } + + // Enumerations + template + static NSString *toMLNRawStyleValue(const MBGLEnum &value) { + return @(mbgl::Enum::toString(value)); + } + + /// Converts all types of mbgl property values into an equivalent NSExpression. + class PropertyExpressionEvaluator { + public: + NSExpression *operator()(const mbgl::style::Undefined) const { return nil; } + + NSExpression *operator()(const MBGLType &value) const { + id constantValue = toMLNRawStyleValue(value); + if ([constantValue isKindOfClass:[NSArray class]]) { + return [NSExpression expressionForAggregate:constantValue]; + } + return [NSExpression expressionForConstantValue:constantValue]; } - NSObject* toRawStyleSpecValue(MLNColor *color, MBGLType &) { - return @(color.mgl_color.stringify().c_str()); + NSExpression *operator()(const mbgl::style::PropertyExpression &mbglValue) const { + return [NSExpression + expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())]; } - - // Bool - void getMBGLValue(NSNumber *rawValue, bool &mbglValue) { - mbglValue = !!rawValue.boolValue; - } - - // Float - void getMBGLValue(NSNumber *rawValue, float &mbglValue) { - mbglValue = rawValue.floatValue; - } - - // String - void getMBGLValue(NSString *rawValue, std::string &mbglValue) { - mbglValue = rawValue.UTF8String; - } - - // Formatted - void getMBGLValue(NSString *rawValue, mbgl::style::expression::Formatted &mbglValue) { - mbglValue = mbgl::style::expression::Formatted(rawValue.UTF8String); - } - - // Offsets - void getMBGLValue(id rawValue, std::array &mbglValue) { - if ([rawValue isKindOfClass:[NSValue class]]) { - mbglValue = [rawValue mgl_offsetArrayValue]; - } else if ([rawValue isKindOfClass:[NSArray class]]) { - NSArray *array = (NSArray *)rawValue; - getMBGLValue(array[0], mbglValue[0]); - getMBGLValue(array[1], mbglValue[1]); - } - } - - // Padding - void getMBGLValue(id rawValue, std::array &mbglValue) { - if ([rawValue isKindOfClass:[NSValue class]]) { - mbglValue = [rawValue mgl_paddingArrayValue]; - } else if ([rawValue isKindOfClass:[NSArray class]]) { - NSArray *array = (NSArray *)rawValue; - getMBGLValue(array[0], mbglValue[0]); - getMBGLValue(array[1], mbglValue[1]); - getMBGLValue(array[2], mbglValue[2]); - getMBGLValue(array[3], mbglValue[3]); - getMBGLValue(array[4], mbglValue[4]); - } - } - - // Color - void getMBGLValue(MLNColor *rawValue, mbgl::Color &mbglValue) { - mbglValue = rawValue.mgl_color; - } - - // Image - void getMBGLValue(NSString *rawValue, mbgl::style::expression::Image &mbglValue) { - mbglValue = mbgl::style::expression::Image(rawValue.UTF8String); - } - - // Array - void getMBGLValue(ObjCType rawValue, std::vector &mbglValue) { - mbglValue.reserve(rawValue.count); - for (id obj in rawValue) { - id constantObject = obj; - if ([obj isKindOfClass:[NSExpression class]] && [obj expressionType] == NSConstantValueExpressionType) { - constantObject = [constantObject constantValue]; - } - MBGLElement mbglElement; - getMBGLValue(constantObject, mbglElement); - mbglValue.push_back(mbglElement); - } - } - - void getMBGLValue(NSValue *rawValue, mbgl::style::Position &mbglValue) { - auto spherical = rawValue.mgl_lightPositionArrayValue; - mbgl::style::Position position(spherical); - mbglValue = position; - } - - // Enumerations - template ::value>::type, - typename MLNEnum = ObjCEnum, - class = typename std::enable_if::value>::type> - void getMBGLValue(id rawValue, MBGLEnum &mbglValue) { - if ([rawValue isKindOfClass:[NSString class]]) { - mbglValue = *mbgl::Enum::toEnum([(NSString *)rawValue UTF8String]); - } else { - MLNEnum mglEnum; - [(NSValue *)rawValue getValue:&mglEnum]; - auto str = mbgl::Enum::toString(mglEnum); - mbglValue = *mbgl::Enum::toEnum(str); - } - } - -private: // Private utilities for converting from mbgl to mgl values - - // Bool - static NSNumber *toMLNRawStyleValue(const bool mbglStopValue) { - return @(mbglStopValue); - } - - // Float - static NSNumber *toMLNRawStyleValue(const float mbglStopValue) { - return @(mbglStopValue); - } - - // Integer - static NSNumber *toMLNRawStyleValue(const int64_t mbglStopValue) { - return @(mbglStopValue); - } - - // String - static NSString *toMLNRawStyleValue(const std::string &mbglStopValue) { - return @(mbglStopValue.c_str()); - } - - // Formatted - static NSString *toMLNRawStyleValue(const mbgl::style::expression::Formatted &mbglStopValue) { - return @(mbglStopValue.toString().c_str()); - } - - // Offsets - static NSValue *toMLNRawStyleValue(const std::array &mbglStopValue) { - return [NSValue mgl_valueWithOffsetArray:mbglStopValue]; - } - - // Padding - static NSValue *toMLNRawStyleValue(const std::array &mbglStopValue) { - return [NSValue mgl_valueWithPaddingArray:mbglStopValue]; - } - - // Color - static MLNColor *toMLNRawStyleValue(const mbgl::Color mbglStopValue) { - return [MLNColor mgl_colorWithColor:mbglStopValue]; - } - - // Image - static NSString *toMLNRawStyleValue(const mbgl::style::expression::Image &mbglImageValue) { - return @(mbglImageValue.id().c_str()); - } - - // Array - static NSArray *toMLNRawStyleValue(const std::vector &mbglStopValue) { - NSMutableArray *array = [NSMutableArray arrayWithCapacity:mbglStopValue.size()]; - for (const auto &mbglElement: mbglStopValue) { - [array addObject:[NSExpression expressionForConstantValue:toMLNRawStyleValue(mbglElement)]]; - } - return array; - } - - static NSValue *toMLNRawStyleValue(const mbgl::style::Position &mbglStopValue) { - std::array spherical = mbglStopValue.getSpherical(); - MLNSphericalPosition position = MLNSphericalPositionMake(spherical[0], spherical[1], spherical[2]); - return [NSValue valueWithMLNSphericalPosition:position]; - } - - // Enumerations - template - static NSString *toMLNRawStyleValue(const MBGLEnum &value) { - return @(mbgl::Enum::toString(value)); - } - - /// Converts all types of mbgl property values into an equivalent NSExpression. - class PropertyExpressionEvaluator { - public: - NSExpression *operator()(const mbgl::style::Undefined) const { - return nil; - } - - NSExpression *operator()(const MBGLType &value) const { - id constantValue = toMLNRawStyleValue(value); - if ([constantValue isKindOfClass:[NSArray class]]) { - return [NSExpression expressionForAggregate:constantValue]; - } - return [NSExpression expressionForConstantValue:constantValue]; - } - - NSExpression *operator()(const mbgl::style::PropertyExpression &mbglValue) const { - return [NSExpression expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())]; - } - }; + }; }; diff --git a/platform/darwin/src/MLNStyle_Private.h b/platform/darwin/src/MLNStyle_Private.h index 8300081bf..ae18d428a 100644 --- a/platform/darwin/src/MLNStyle_Private.h +++ b/platform/darwin/src/MLNStyle_Private.h @@ -1,15 +1,15 @@ #import "MLNStyle.h" -#import "MLNStyleLayer.h" #import "MLNFillStyleLayer.h" +#import "MLNStyleLayer.h" NS_ASSUME_NONNULL_BEGIN namespace mbgl { - namespace style { - class Style; - } +namespace style { +class Style; } +} // namespace mbgl @class MLNAttributionInfo; @class MLNMapView; @@ -19,14 +19,18 @@ namespace mbgl { @interface MLNStyle (Private) -- (instancetype)initWithRawStyle:(mbgl::style::Style *)rawStyle stylable:(id )stylable; +- (instancetype)initWithRawStyle:(mbgl::style::Style *)rawStyle stylable:(id)stylable; -@property (nonatomic, readonly, weak) id stylable; +@property (nonatomic, readonly, weak) id stylable; @property (nonatomic, readonly) mbgl::style::Style *rawStyle; -- (nullable NSArray *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MLNColor *)linkColor; -@property (nonatomic, readonly, strong) NSMutableDictionary *customLayers; -- (void)setStyleClasses:(NSArray *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration; +- (nullable NSArray *)attributionInfosWithFontSize:(CGFloat)fontSize + linkColor: + (nullable MLNColor *)linkColor; +@property (nonatomic, readonly, strong) + NSMutableDictionary *customLayers; +- (void)setStyleClasses:(NSArray *)appliedClasses + transitionDuration:(NSTimeInterval)transitionDuration; @end diff --git a/platform/darwin/src/MLNTilePyramidOfflineRegion.h b/platform/darwin/src/MLNTilePyramidOfflineRegion.h index 287c01ae2..8c6fb8511 100644 --- a/platform/darwin/src/MLNTilePyramidOfflineRegion.h +++ b/platform/darwin/src/MLNTilePyramidOfflineRegion.h @@ -1,29 +1,29 @@ #import #import "MLNFoundation.h" -#import "MLNOfflineRegion.h" #import "MLNGeometry.h" +#import "MLNOfflineRegion.h" NS_ASSUME_NONNULL_BEGIN /** An offline region defined by a style URL, geographic coordinate bounds, and range of zoom levels. - + To minimize the resources required by an irregularly shaped offline region, use the MLNShapeOfflineRegion class instead. - + ### Example ```swift let northeast = CLLocationCoordinate2D(latitude: 40.989329, longitude: -102.062592) let southwest = CLLocationCoordinate2D(latitude: 36.986207, longitude: -109.049896) let bbox = MLNCoordinateBounds(sw: southwest, ne: northeast) - - let region = MLNTilePyramidOfflineRegion(styleURL: MLNStyle.lightStyleURL, bounds: bbox, fromZoomLevel: 11, toZoomLevel: 14) - let context = "Tile Pyramid Region".data(using: .utf8) + + let region = MLNTilePyramidOfflineRegion(styleURL: MLNStyle.lightStyleURL, bounds: bbox, + fromZoomLevel: 11, toZoomLevel: 14) let context = "Tile Pyramid Region".data(using: .utf8) MLNOfflineStorage.shared.addPack(for: region, withContext: context!) ``` - + #### Related examples TODO: Download an offline map, learn how to define an offline region to be downloaded to a user's device. @@ -80,7 +80,10 @@ MLN_EXPORT level, the download covers zoom levels up to the tile source’s maximum zoom level. */ -- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL bounds:(MLNCoordinateBounds)bounds fromZoomLevel:(double)minimumZoomLevel toZoomLevel:(double)maximumZoomLevel NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithStyleURL:(nullable NSURL *)styleURL + bounds:(MLNCoordinateBounds)bounds + fromZoomLevel:(double)minimumZoomLevel + toZoomLevel:(double)maximumZoomLevel NS_DESIGNATED_INITIALIZER; @end diff --git a/platform/darwin/src/MLNTilePyramidOfflineRegion_Private.h b/platform/darwin/src/MLNTilePyramidOfflineRegion_Private.h index eb88e4c9c..f601268ba 100644 --- a/platform/darwin/src/MLNTilePyramidOfflineRegion_Private.h +++ b/platform/darwin/src/MLNTilePyramidOfflineRegion_Private.h @@ -15,7 +15,8 @@ NS_ASSUME_NONNULL_BEGIN @param definition A reference to an offline region definition backing the offline region. */ -- (instancetype)initWithOfflineRegionDefinition:(const mbgl::OfflineTilePyramidRegionDefinition &)definition; +- (instancetype)initWithOfflineRegionDefinition: + (const mbgl::OfflineTilePyramidRegionDefinition &)definition; @end diff --git a/platform/darwin/src/MLNTileServerOptions.h b/platform/darwin/src/MLNTileServerOptions.h index 8c81845db..2b74cbfd9 100644 --- a/platform/darwin/src/MLNTileServerOptions.h +++ b/platform/darwin/src/MLNTileServerOptions.h @@ -1,7 +1,7 @@ #import -#import "MLNFoundation.h" #import "MLNDefaultStyle.h" +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN @@ -12,98 +12,98 @@ MLN_EXPORT @interface MLNTileServerOptions : NSObject /** -* API base URL. -*/ -@property (nonatomic,retain) NSString* baseURL; - -/** -* Tile server URI alias. -*/ -@property (nonatomic,retain) NSString* uriSchemeAlias; + * API base URL. + */ +@property (nonatomic, retain) NSString* baseURL; /** -* URL template for sources. -*/ -@property (nonatomic,retain) NSString* sourceTemplate; + * Tile server URI alias. + */ +@property (nonatomic, retain) NSString* uriSchemeAlias; /** -* source domain name. -*/ -@property (nonatomic,retain) NSString* sourceDomainName; - -/** -* source version prefix -*/ -@property (nonatomic,retain,nullable) NSString* sourceVersionPrefix; + * URL template for sources. + */ +@property (nonatomic, retain) NSString* sourceTemplate; /** -* URL template for style. -*/ -@property (nonatomic,retain) NSString* styleTemplate; - -/** -* style domain name. -*/ -@property (nonatomic,retain) NSString* styleDomainName; - -/** -* style version prefix -*/ -@property (nonatomic,retain,nullable) NSString* styleVersionPrefix; + * source domain name. + */ +@property (nonatomic, retain) NSString* sourceDomainName; /** -* URL template for sprites. -*/ -@property (nonatomic,retain) NSString* spritesTemplate; - -/** -* sprites domain name. -*/ -@property (nonatomic,retain) NSString* spritesDomainName; + * source version prefix + */ +@property (nonatomic, retain, nullable) NSString* sourceVersionPrefix; /** -* version prefix -*/ -@property (nonatomic,retain,nullable) NSString* spritesVersionPrefix; + * URL template for style. + */ +@property (nonatomic, retain) NSString* styleTemplate; /** -* URL template for glyphs. -*/ -@property (nonatomic,retain) NSString* glyphsTemplate; + * style domain name. + */ +@property (nonatomic, retain) NSString* styleDomainName; /** -* glyphs domain name. -*/ -@property (nonatomic,retain) NSString* glyphsDomainName; + * style version prefix + */ +@property (nonatomic, retain, nullable) NSString* styleVersionPrefix; /** -* Glyphs version prefix -*/ -@property (nonatomic,retain,nullable) NSString* glyphsVersionPrefix; + * URL template for sprites. + */ +@property (nonatomic, retain) NSString* spritesTemplate; /** -* URL template for tiles. -*/ -@property (nonatomic,retain) NSString* tileTemplate; + * sprites domain name. + */ +@property (nonatomic, retain) NSString* spritesDomainName; /** -* tile domain name. -*/ -@property (nonatomic,retain) NSString* tileDomainName; + * version prefix + */ +@property (nonatomic, retain, nullable) NSString* spritesVersionPrefix; /** -* tile version prefix -*/ -@property (nonatomic,retain,nullable) NSString* tileVersionPrefix; - -/** -* API key parameter name. -*/ -@property (nonatomic,retain) NSString* apiKeyParameterName; + * URL template for glyphs. + */ +@property (nonatomic, retain) NSString* glyphsTemplate; /** -* Default styles. -*/ + * glyphs domain name. + */ +@property (nonatomic, retain) NSString* glyphsDomainName; + +/** + * Glyphs version prefix + */ +@property (nonatomic, retain, nullable) NSString* glyphsVersionPrefix; + +/** + * URL template for tiles. + */ +@property (nonatomic, retain) NSString* tileTemplate; + +/** + * tile domain name. + */ +@property (nonatomic, retain) NSString* tileDomainName; + +/** + * tile version prefix + */ +@property (nonatomic, retain, nullable) NSString* tileVersionPrefix; + +/** + * API key parameter name. + */ +@property (nonatomic, retain) NSString* apiKeyParameterName; + +/** + * Default styles. + */ @property (nonatomic, retain) NSArray* defaultStyles; /** diff --git a/platform/darwin/src/MLNTileSource.h b/platform/darwin/src/MLNTileSource.h index 86f8a543e..6a9dcf571 100644 --- a/platform/darwin/src/MLNTileSource.h +++ b/platform/darwin/src/MLNTileSource.h @@ -44,7 +44,7 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNTileSourceOption MLNTileSourceOptionMaximu /** An `NSValue` object containing an `MLNCoordinateBounds` struct that specifies the geographic extent of the source. - + If this option is specified, the SDK avoids requesting any tile that falls outside of the coordinate bounds. Otherwise, the SDK requests any tile needed to cover the viewport, as it does by default. @@ -122,23 +122,24 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNTileSourceOption MLNTileSourceOptionTileCo interpreted. */ typedef NS_ENUM(NSUInteger, MLNTileCoordinateSystem) { - /** - The origin is at the top-left (northwest), and `y` values increase - southwards. + /** + The origin is at the top-left (northwest), and `y` values increase + southwards. - This tile coordinate system is used by Mapbox and OpenStreetMap tile - servers. - */ - MLNTileCoordinateSystemXYZ = 0, + This tile coordinate system is used by Mapbox and OpenStreetMap tile + servers. + */ + MLNTileCoordinateSystemXYZ = 0, - /** - The origin is at the bottom-left (southwest), and `y` values increase - northwards. + /** + The origin is at the bottom-left (southwest), and `y` values increase + northwards. - This tile coordinate system is used by tile servers that conform to the - Tile Map Service Specification. - */ - MLNTileCoordinateSystemTMS + This tile coordinate system is used by tile servers that conform to the + Tile Map Service + Specification. + */ + MLNTileCoordinateSystemTMS }; /** @@ -147,15 +148,17 @@ typedef NS_ENUM(NSUInteger, MLNTileCoordinateSystem) { typedef NS_ENUM(NSUInteger, MLNDEMEncoding) { - /** - Raster tiles generated with the [Mapbox encoding formula](https://docs.mapbox.com/help/troubleshooting/access-elevation-data/#mapbox-terrain-rgb). - */ - MLNDEMEncodingMapbox = 0, + /** + Raster tiles generated with the [Mapbox encoding + formula](https://docs.mapbox.com/help/troubleshooting/access-elevation-data/#mapbox-terrain-rgb). + */ + MLNDEMEncodingMapbox = 0, - /** - Raster tiles generated with the [Mapzen Terrarium encoding formula](https://aws.amazon.com/public-datasets/terrain/). - */ - MLNDEMEncodingTerrarium + /** + Raster tiles generated with the [Mapzen Terrarium encoding + formula](https://aws.amazon.com/public-datasets/terrain/). + */ + MLNDEMEncodingTerrarium }; /** @@ -166,7 +169,7 @@ typedef NS_ENUM(NSUInteger, MLNDEMEncoding) { A tile source is added to an `MLNStyle` object along with one or more `MLNRasterStyleLayer` or `MLNVectorStyleLayer` objects. Use a style layer to control the appearance of content supplied by the tile source. - + A tile source is also known as a tile set. To learn about the structure of a Mapbox-hosted tile set, view it in Mapbox Studio’s Tilesets editor. diff --git a/platform/darwin/src/MLNTileSource_Private.h b/platform/darwin/src/MLNTileSource_Private.h index 9942c8b53..8e16c6c4a 100644 --- a/platform/darwin/src/MLNTileSource_Private.h +++ b/platform/darwin/src/MLNTileSource_Private.h @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN namespace mbgl { - class Tileset; +class Tileset; } @class MLNAttributionInfo; @@ -28,11 +28,14 @@ namespace mbgl { @param fontSize The default text size in points, or 0 to use the default. @param linkColor The default link color, or `nil` to use the default. */ -- (NSArray *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MLNColor *)linkColor; +- (NSArray *)attributionInfosWithFontSize:(CGFloat)fontSize + linkColor:(nullable MLNColor *)linkColor; @end MLN_EXPORT -mbgl::Tileset MLNTileSetFromTileURLTemplates(NSArray *tileURLTemplates, NSDictionary * _Nullable options); +mbgl::Tileset MLNTileSetFromTileURLTemplates( + NSArray *tileURLTemplates, + NSDictionary *_Nullable options); NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MLNTypes.h b/platform/darwin/src/MLNTypes.h index 4834504e8..4e8056be6 100644 --- a/platform/darwin/src/MLNTypes.h +++ b/platform/darwin/src/MLNTypes.h @@ -1,5 +1,5 @@ -#import #import +#import #import "MLNFoundation.h" @@ -36,55 +36,55 @@ FOUNDATION_EXTERN MLN_EXPORT NSErrorDomain const MLNErrorDomain; /** Error constants for the Mapbox SDK. */ typedef NS_ENUM(NSInteger, MLNErrorCode) { - /** An unknown error occurred. */ - MLNErrorCodeUnknown = -1, - /** The resource could not be found. */ - MLNErrorCodeNotFound = 1, - /** The connection received an invalid server response. */ - MLNErrorCodeBadServerResponse = 2, - /** An attempt to establish a connection failed. */ - MLNErrorCodeConnectionFailed = 3, - /** A style parse error occurred while attempting to load the map. */ - MLNErrorCodeParseStyleFailed = 4, - /** An attempt to load the style failed. */ - MLNErrorCodeLoadStyleFailed = 5, - /** An error occurred while snapshotting the map. */ - MLNErrorCodeSnapshotFailed = 6, - /** Source is in use and cannot be removed */ - MLNErrorCodeSourceIsInUseCannotRemove = 7, - /** Source is in use and cannot be removed */ - MLNErrorCodeSourceIdentifierMismatch = 8, - /** An error occurred while modifying the offline storage database */ - MLNErrorCodeModifyingOfflineStorageFailed = 9, - /** Source is invalid and cannot be removed from the style (e.g. after a style change) */ - MLNErrorCodeSourceCannotBeRemovedFromStyle = 10, - /** An error occurred while rendering */ - MLNErrorCodeRenderingError = 11, + /** An unknown error occurred. */ + MLNErrorCodeUnknown = -1, + /** The resource could not be found. */ + MLNErrorCodeNotFound = 1, + /** The connection received an invalid server response. */ + MLNErrorCodeBadServerResponse = 2, + /** An attempt to establish a connection failed. */ + MLNErrorCodeConnectionFailed = 3, + /** A style parse error occurred while attempting to load the map. */ + MLNErrorCodeParseStyleFailed = 4, + /** An attempt to load the style failed. */ + MLNErrorCodeLoadStyleFailed = 5, + /** An error occurred while snapshotting the map. */ + MLNErrorCodeSnapshotFailed = 6, + /** Source is in use and cannot be removed */ + MLNErrorCodeSourceIsInUseCannotRemove = 7, + /** Source is in use and cannot be removed */ + MLNErrorCodeSourceIdentifierMismatch = 8, + /** An error occurred while modifying the offline storage database */ + MLNErrorCodeModifyingOfflineStorageFailed = 9, + /** Source is invalid and cannot be removed from the style (e.g. after a style change) */ + MLNErrorCodeSourceCannotBeRemovedFromStyle = 10, + /** An error occurred while rendering */ + MLNErrorCodeRenderingError = 11, }; /** Options for enabling debugging features in an `MLNMapView` instance. */ typedef NS_OPTIONS(NSUInteger, MLNMapDebugMaskOptions) { - /** Edges of tile boundaries are shown as thick, red lines to help diagnose - tile clipping issues. */ - MLNMapDebugTileBoundariesMask = 1 << 1, - /** Each tile shows its tile coordinate (x/y/z) in the upper-left corner. */ - MLNMapDebugTileInfoMask = 1 << 2, - /** Each tile shows a timestamp indicating when it was loaded. */ - MLNMapDebugTimestampsMask = 1 << 3, - /** Edges of glyphs and symbols are shown as faint, green lines to help - diagnose collision and label placement issues. */ - MLNMapDebugCollisionBoxesMask = 1 << 4, - /** Each drawing operation is replaced by a translucent fill. Overlapping - drawing operations appear more prominent to help diagnose overdrawing. - @note This option does nothing in Release builds of the SDK. */ - MLNMapDebugOverdrawVisualizationMask = 1 << 5, + /** Edges of tile boundaries are shown as thick, red lines to help diagnose + tile clipping issues. */ + MLNMapDebugTileBoundariesMask = 1 << 1, + /** Each tile shows its tile coordinate (x/y/z) in the upper-left corner. */ + MLNMapDebugTileInfoMask = 1 << 2, + /** Each tile shows a timestamp indicating when it was loaded. */ + MLNMapDebugTimestampsMask = 1 << 3, + /** Edges of glyphs and symbols are shown as faint, green lines to help + diagnose collision and label placement issues. */ + MLNMapDebugCollisionBoxesMask = 1 << 4, + /** Each drawing operation is replaced by a translucent fill. Overlapping + drawing operations appear more prominent to help diagnose overdrawing. + @note This option does nothing in Release builds of the SDK. */ + MLNMapDebugOverdrawVisualizationMask = 1 << 5, #if !TARGET_OS_IPHONE - /** The stencil buffer is shown instead of the color buffer. - @note This option does nothing in Release builds of the SDK. */ - MLNMapDebugStencilBufferMask = 1 << 6, - /** The depth buffer is shown instead of the color buffer. - @note This option does nothing in Release builds of the SDK. */ - MLNMapDebugDepthBufferMask = 1 << 7, + /** The stencil buffer is shown instead of the color buffer. + @note This option does nothing in Release builds of the SDK. */ + MLNMapDebugStencilBufferMask = 1 << 6, + /** The depth buffer is shown instead of the color buffer. + @note This option does nothing in Release builds of the SDK. */ + MLNMapDebugDepthBufferMask = 1 << 7, #endif }; @@ -92,49 +92,50 @@ typedef NS_OPTIONS(NSUInteger, MLNMapDebugMaskOptions) { A structure containing information about a transition. */ typedef struct __attribute__((objc_boxable)) MLNTransition { - /** - The amount of time the animation should take, not including the delay. - */ - NSTimeInterval duration; - - /** - The amount of time in seconds to wait before beginning the animation. - */ - NSTimeInterval delay; + /** + The amount of time the animation should take, not including the delay. + */ + NSTimeInterval duration; + + /** + The amount of time in seconds to wait before beginning the animation. + */ + NSTimeInterval delay; } MLNTransition; NS_INLINE NSString *MLNStringFromMLNTransition(MLNTransition transition) { - return [NSString stringWithFormat:@"transition { duration: %f, delay: %f }", transition.duration, transition.delay]; + return [NSString stringWithFormat:@"transition { duration: %f, delay: %f }", transition.duration, + transition.delay]; } /** Creates a new `MLNTransition` from the given duration and delay. - - @param duration The amount of time the animation should take, not including + + @param duration The amount of time the animation should take, not including the delay. - @param delay The amount of time in seconds to wait before beginning the + @param delay The amount of time in seconds to wait before beginning the animation. - + @return Returns a `MLNTransition` struct containing the transition attributes. */ NS_INLINE MLNTransition MLNTransitionMake(NSTimeInterval duration, NSTimeInterval delay) { - MLNTransition transition; - transition.duration = duration; - transition.delay = delay; - - return transition; + MLNTransition transition; + transition.duration = duration; + transition.delay = delay; + + return transition; } /** Constants indicating the visibility of different map ornaments. */ typedef NS_ENUM(NSInteger, MLNOrnamentVisibility) { - /** A constant indicating that the ornament adapts to the current map state. */ - MLNOrnamentVisibilityAdaptive, - /** A constant indicating that the ornament is always hidden. */ - MLNOrnamentVisibilityHidden, - /** A constant indicating that the ornament is always visible. */ - MLNOrnamentVisibilityVisible + /** A constant indicating that the ornament adapts to the current map state. */ + MLNOrnamentVisibilityAdaptive, + /** A constant indicating that the ornament is always hidden. */ + MLNOrnamentVisibilityHidden, + /** A constant indicating that the ornament is always visible. */ + MLNOrnamentVisibilityVisible }; NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MLNValueEvaluator.h b/platform/darwin/src/MLNValueEvaluator.h index 2779deba9..616c60143 100644 --- a/platform/darwin/src/MLNValueEvaluator.h +++ b/platform/darwin/src/MLNValueEvaluator.h @@ -6,44 +6,32 @@ Recursively transforms a C++ type into the corresponding Foundation type. */ class ValueEvaluator { -public: - id operator()(const mbgl::NullValue &) const { - return [NSNull null]; - } + public: + id operator()(const mbgl::NullValue &) const { return [NSNull null]; } - id operator()(const bool &value) const { - return value ? @YES : @NO; - } + id operator()(const bool &value) const { return value ? @YES : @NO; } - id operator()(const uint64_t &value) const { - return @(value); - } + id operator()(const uint64_t &value) const { return @(value); } - id operator()(const int64_t &value) const { - return @(value); - } + id operator()(const int64_t &value) const { return @(value); } - id operator()(const double &value) const { - return @(value); - } + id operator()(const double &value) const { return @(value); } - id operator()(const std::string &value) const { - return @(value.c_str()); - } + id operator()(const std::string &value) const { return @(value.c_str()); } - id operator()(const std::vector &values) const { - NSMutableArray *objects = [NSMutableArray arrayWithCapacity:values.size()]; - for (const auto &v : values) { - [objects addObject:mbgl::Value::visit(v, *this)]; - } - return objects; + id operator()(const std::vector &values) const { + NSMutableArray *objects = [NSMutableArray arrayWithCapacity:values.size()]; + for (const auto &v : values) { + [objects addObject:mbgl::Value::visit(v, *this)]; } + return objects; + } - id operator()(const std::unordered_map &items) const { - NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:items.size()]; - for (auto &item : items) { - attributes[@(item.first.c_str())] = mbgl::Value::visit(item.second, *this); - } - return attributes; + id operator()(const std::unordered_map &items) const { + NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:items.size()]; + for (auto &item : items) { + attributes[@(item.first.c_str())] = mbgl::Value::visit(item.second, *this); } + return attributes; + } }; diff --git a/platform/darwin/src/MLNVectorStyleLayer.h b/platform/darwin/src/MLNVectorStyleLayer.h index dee127551..825f59efa 100644 --- a/platform/darwin/src/MLNVectorStyleLayer.h +++ b/platform/darwin/src/MLNVectorStyleLayer.h @@ -1,7 +1,7 @@ #import -#import "MLNFoundation.h" #import "MLNForegroundStyleLayer.h" +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN @@ -34,7 +34,7 @@ MLN_EXPORT comes from the style, its predicate corresponds to the `filter` property in the style JSON. - + See the “Predicates and Expressions” guide for details about the predicate syntax supported by this class. @@ -47,8 +47,8 @@ MLN_EXPORT ```swift let layer = MLNLineStyleLayer(identifier: "contour", source: terrain) layer.sourceLayerIdentifier = "contours" - layer.predicate = NSPredicate(format: "(index == 5 || index == 10) && CAST(ele, 'NSNumber') >= 1500.0") - mapView.style?.addLayer(layer) + layer.predicate = NSPredicate(format: "(index == 5 || index == 10) && CAST(ele, 'NSNumber') >= + 1500.0") mapView.style?.addLayer(layer) ``` */ @property (nonatomic, nullable) NSPredicate *predicate; diff --git a/platform/darwin/src/MLNVectorTileSource.h b/platform/darwin/src/MLNVectorTileSource.h index a06a49e1d..d845b15ad 100644 --- a/platform/darwin/src/MLNVectorTileSource.h +++ b/platform/darwin/src/MLNVectorTileSource.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN A vector tile source is added to an `MLNStyle` object along with one or more `MLNVectorStyleLayer` objects. A vector style layer defines the appearance of any content supplied by the vector tile source. - + `MLNVectorTileSource` is optimized for data sets that are too large to fit completely in memory, such as vector tile sets or data sets managed in Mapbox Studio. For @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN (extent × 2) − 1, inclusive. Any vector style layer initialized with a vector tile source must have a non-`nil` value in its `sourceLayerIdentifier` property. - + Commonly used vector tile sources include Mapbox Streets, Mapbox Terrain, @@ -44,16 +44,17 @@ NS_ASSUME_NONNULL_BEGIN ### Example ```swift - let source = MLNVectorTileSource(identifier: "pois", tileURLTemplates: ["https://example.com/vector-tiles/{z}/{x}/{y}.mvt"], options: [ - .minimumZoomLevel: 9, + let source = MLNVectorTileSource(identifier: "pois", tileURLTemplates: + ["https://example.com/vector-tiles/{z}/{x}/{y}.mvt"], options: [ .minimumZoomLevel: 9, .maximumZoomLevel: 16, .attributionInfos: [ - MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) + MLNAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: + "https://mapbox.com")) ] ]) mapView.style?.addSource(source) ``` - + #### Related examples TODO: Data-driven circles, learn how to add data to your map using an `MLNVectorTileSource` object. @@ -80,7 +81,8 @@ MLN_EXPORT source’s contents and other metadata. @return An initialized vector tile source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier configurationURL:(NSURL *)configurationURL NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + configurationURL:(NSURL *)configurationURL NS_DESIGNATED_INITIALIZER; /** Returns a vector tile source initialized an identifier, tile URL templates, and @@ -102,7 +104,10 @@ MLN_EXPORT the default values. @return An initialized tile source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier tileURLTemplates:(NSArray *)tileURLTemplates options:(nullable NSDictionary *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier + tileURLTemplates:(NSArray *)tileURLTemplates + options:(nullable NSDictionary *)options + NS_DESIGNATED_INITIALIZER; // MARK: Accessing a Source’s Content @@ -123,7 +128,7 @@ MLN_EXPORT includes those parts of the road that lie within the map tiles that the source has loaded, even if the road extends into other tiles. The portion of the road within each map tile is included individually. - + Returned features may not necessarily be visible to the user at the time they are loaded: the style may contain a layer that forces the source’s tiles to load but filters out the features in question, preventing them from being @@ -141,7 +146,10 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features loaded by the source that match the predicate. */ -- (NSArray> *)featuresInSourceLayersWithIdentifiers:(NSSet *)sourceLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(features(sourceLayerIdentifiers:predicate:)); +- (NSArray> *)featuresInSourceLayersWithIdentifiers: + (NSSet *)sourceLayerIdentifiers + predicate:(nullable NSPredicate *)predicate + NS_SWIFT_NAME(features(sourceLayerIdentifiers:predicate:)); @end diff --git a/platform/darwin/src/MLNVectorTileSource_Private.h b/platform/darwin/src/MLNVectorTileSource_Private.h index 5829221f5..9a598c2b8 100644 --- a/platform/darwin/src/MLNVectorTileSource_Private.h +++ b/platform/darwin/src/MLNVectorTileSource_Private.h @@ -9,7 +9,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSSet *)mapboxStreetsLanguages; + (nullable NSString *)preferredMapboxStreetsLanguage; -+ (nullable NSString *)preferredMapboxStreetsLanguageForPreferences:(NSArray *)preferencesArray; ++ (nullable NSString *)preferredMapboxStreetsLanguageForPreferences: + (NSArray *)preferencesArray; @end diff --git a/platform/darwin/src/NSArray+MLNAdditions.h b/platform/darwin/src/NSArray+MLNAdditions.h index 217f1a668..76fd0e4c8 100644 --- a/platform/darwin/src/NSArray+MLNAdditions.h +++ b/platform/darwin/src/NSArray+MLNAdditions.h @@ -1,5 +1,5 @@ -#import #import +#import #import @@ -7,7 +7,8 @@ - (std::vector)mgl_vector; -/** Returns a string resulting from inserting a separator between each attributed string in the array */ +/** Returns a string resulting from inserting a separator between each attributed string in the + * array */ - (NSAttributedString *)mgl_attributedComponentsJoinedByString:(NSString *)separator; /** diff --git a/platform/darwin/src/NSBundle+MLNAdditions.h b/platform/darwin/src/NSBundle+MLNAdditions.h index 136171e83..7e1fa52a3 100644 --- a/platform/darwin/src/NSBundle+MLNAdditions.h +++ b/platform/darwin/src/NSBundle+MLNAdditions.h @@ -17,15 +17,15 @@ NS_ASSUME_NONNULL_BEGIN #undef NSLocalizedString #define NSLocalizedString(key, comment) \ - [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:@"" table:nil] + [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:@"" table:nil] #undef NSLocalizedStringFromTable #define NSLocalizedStringFromTable(key, tbl, comment) \ - [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:@"" table:(tbl)] + [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:@"" table:(tbl)] #undef NSLocalizedStringWithDefaultValue #define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) \ - [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:(val) table:(tbl)] + [[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:(val)table:(tbl)] FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNBundleNotFoundException; diff --git a/platform/darwin/src/NSCoder+MLNAdditions.h b/platform/darwin/src/NSCoder+MLNAdditions.h index 80e8a92d3..abc287617 100644 --- a/platform/darwin/src/NSCoder+MLNAdditions.h +++ b/platform/darwin/src/NSCoder+MLNAdditions.h @@ -1,5 +1,5 @@ -#import #import +#import #import @@ -9,7 +9,8 @@ - (CLLocationCoordinate2D)decodeMLNCoordinateForKey:(NSString *)key; -- (void)mgl_encodeLocationCoordinates2D:(std::vector)coordinates forKey:(NSString *)key; +- (void)mgl_encodeLocationCoordinates2D:(std::vector)coordinates + forKey:(NSString *)key; - (std::vector)mgl_decodeLocationCoordinates2DForKey:(NSString *)key; diff --git a/platform/darwin/src/NSDate+MLNAdditions.h b/platform/darwin/src/NSDate+MLNAdditions.h index cb0e2f98e..0e0345129 100644 --- a/platform/darwin/src/NSDate+MLNAdditions.h +++ b/platform/darwin/src/NSDate+MLNAdditions.h @@ -1,11 +1,10 @@ #import -#import "MLNFoundation.h" #include +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN - /// Converts from a duration in seconds to a duration object usable in mbgl. MLN_EXPORT mbgl::Duration MLNDurationFromTimeInterval(NSTimeInterval duration); diff --git a/platform/darwin/src/NSException+MLNAdditions.h b/platform/darwin/src/NSException+MLNAdditions.h index 89e62d172..93f821773 100644 --- a/platform/darwin/src/NSException+MLNAdditions.h +++ b/platform/darwin/src/NSException+MLNAdditions.h @@ -1,4 +1,7 @@ #import #import "MLNLoggingConfiguration_Private.h" -#define MLNAssertIsMainThread() MLNAssert([[NSThread currentThread] isMainThread], @"%s must be accessed on the main thread, not %@", __PRETTY_FUNCTION__, [NSThread currentThread]) +#define MLNAssertIsMainThread() \ + MLNAssert([[NSThread currentThread] isMainThread], \ + @"%s must be accessed on the main thread, not %@", __PRETTY_FUNCTION__, \ + [NSThread currentThread]) diff --git a/platform/darwin/src/NSExpression+MLNAdditions.h b/platform/darwin/src/NSExpression+MLNAdditions.h index 8173c582e..ab842c12b 100644 --- a/platform/darwin/src/NSExpression+MLNAdditions.h +++ b/platform/darwin/src/NSExpression+MLNAdditions.h @@ -1,8 +1,8 @@ #import #if TARGET_OS_IPHONE - #import +#import #else - #import +#import #endif #import "MLNTypes.h" @@ -15,30 +15,36 @@ typedef NSString *MLNExpressionInterpolationMode NS_TYPED_ENUM; /** An `NSString` identifying the `linear` interpolation type in an `NSExpression`. - + This attribute corresponds to the `linear` value in the - interpolate + interpolate expression operator in the MapLibre Style Spec. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionInterpolationModeLinear; +FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode + MLNExpressionInterpolationModeLinear; /** An `NSString` identifying the `expotential` interpolation type in an `NSExpression`. - + This attribute corresponds to the `exponential` value in the - interpolate + interpolate expression operator in the MapLibre Style Spec. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionInterpolationModeExponential; +FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode + MLNExpressionInterpolationModeExponential; /** An `NSString` identifying the `cubic-bezier` interpolation type in an `NSExpression`. - + This attribute corresponds to the `cubic-bezier` value in the - interpolate + interpolate expression operator in the MapLibre Style Spec. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionInterpolationModeCubicBezier; +FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode + MLNExpressionInterpolationModeCubicBezier; /** Methods for creating expressions that use Mapbox-specific functionality and for @@ -58,21 +64,24 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI /** `NSExpression` variable that corresponds to the - heatmap-density + heatmap-density expression operator in the MapLibre Style Spec. */ @property (class, nonatomic, readonly) NSExpression *heatmapDensityVariableExpression; /** `NSExpression` variable that corresponds to the - line-progress + line-progress expression operator in the MapLibre Style Spec. */ @property (class, nonatomic, readonly) NSExpression *lineProgressVariableExpression; /** `NSExpression` variable that corresponds to the - geometry-type + geometry-type expression operator in the MapLibre Style Spec. */ @property (class, nonatomic, readonly) NSExpression *geometryTypeVariableExpression; @@ -93,103 +102,124 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI /** `NSExpression` variable that corresponds to the - properties + properties expression operator in the MapLibre Style Spec. */ @property (class, nonatomic, readonly) NSExpression *featureAttributesVariableExpression; -@property (class, nonatomic, readonly) NSExpression *featurePropertiesVariableExpression __attribute__((deprecated("", "featureAttributesVariableExpression"))); +@property (class, nonatomic, readonly) NSExpression *featurePropertiesVariableExpression + __attribute__((deprecated("", "featureAttributesVariableExpression"))); // MARK: Creating Conditional Expressions /** Returns a conditional function expression specifying the string predicate, and expressions for each condition. - + @param conditionPredicate The predicate to get evaluated. @param trueExpression The expression for conditions equal to true. @param falseExpression The expression for conditions equal to false. */ -+ (instancetype)mgl_expressionForConditional:(nonnull NSPredicate *)conditionPredicate trueExpression:(nonnull NSExpression *)trueExpression falseExpresssion:(nonnull NSExpression *)falseExpression NS_SWIFT_NAME(init(forMLNConditional:trueExpression:falseExpression:)); ++ (instancetype)mgl_expressionForConditional:(nonnull NSPredicate *)conditionPredicate + trueExpression:(nonnull NSExpression *)trueExpression + falseExpresssion:(nonnull NSExpression *)falseExpression + NS_SWIFT_NAME(init(forMLNConditional:trueExpression:falseExpression:)); // MARK: Creating Ramp, Scale, and Curve Expressions /** Returns a step function expression specifying the stepping, from expression and stops. - + @param steppingExpression The stepping expression. @param minimumExpression The expression which could be a constant or function expression. @param stops The stops must be an `NSDictionary` constant `NSExpression`. - + #### Related examples TODO: Data-driven circles TODO: Cluster point data TODO: Use images to cluster point data Learn how to use this expression to style a map layer based on an attribute value. */ -+ (instancetype)mgl_expressionForSteppingExpression:(nonnull NSExpression*)steppingExpression fromExpression:(nonnull NSExpression *)minimumExpression stops:(nonnull NSExpression*)stops NS_SWIFT_NAME(init(forMLNStepping:from:stops:)); ++ (instancetype)mgl_expressionForSteppingExpression:(nonnull NSExpression *)steppingExpression + fromExpression:(nonnull NSExpression *)minimumExpression + stops:(nonnull NSExpression *)stops + NS_SWIFT_NAME(init(forMLNStepping:from:stops:)); /** Returns an interpolated function expression specifying the function operator, curve type, parameters and steps. - + @param inputExpression The interpolating expression input. @param curveType The curve type could be `MLNExpressionInterpolationModeLinear`, `MLNExpressionInterpolationModeExponential` and `MLNExpressionInterpolationModeCubicBezier`. @param parameters The parameters expression. @param stops The stops expression. - + #### Related examples TODO: Create a heatmap layer, learn how to style an `MLNHeatmapStyleLayer` based on zoom level and point density with this expression. */ -+ (instancetype)mgl_expressionForInterpolatingExpression:(nonnull NSExpression*)inputExpression withCurveType:(nonnull MLNExpressionInterpolationMode)curveType parameters:(nullable NSExpression *)parameters stops:(nonnull NSExpression*)stops NS_SWIFT_NAME(init(forMLNInterpolating:curveType:parameters:stops:)); ++ (instancetype)mgl_expressionForInterpolatingExpression:(nonnull NSExpression *)inputExpression + withCurveType: + (nonnull MLNExpressionInterpolationMode)curveType + parameters:(nullable NSExpression *)parameters + stops:(nonnull NSExpression *)stops + NS_SWIFT_NAME(init(forMLNInterpolating:curveType:parameters:stops:)); /** Returns a match function expression specifying the input, matching values, and default value. - + @param inputExpression The matching expression. @param matchedExpressions The matched values expression dictionary must be condition : value. @param defaultExpression The defaultValue expression to be used in case there is no match. */ -+ (instancetype)mgl_expressionForMatchingExpression:(nonnull NSExpression *)inputExpression inDictionary:(nonnull NSDictionary *)matchedExpressions defaultExpression:(nonnull NSExpression *)defaultExpression NS_SWIFT_NAME(init(forMLNMatchingKey:in:default:)); ++ (instancetype)mgl_expressionForMatchingExpression:(nonnull NSExpression *)inputExpression + inDictionary: + (nonnull NSDictionary *) + matchedExpressions + defaultExpression:(nonnull NSExpression *)defaultExpression + NS_SWIFT_NAME(init(forMLNMatchingKey:in:default:)); /** Returns an attributed function expression specifying an `MLNAttributedExpression` constant expression array. - + @param attributedExpressions The `MLNAttributedExpression` constant expression array. */ -+ (instancetype)mgl_expressionForAttributedExpressions:(nonnull NSArray *)attributedExpressions NS_SWIFT_NAME(init(forAttributedExpressions:)); ++ (instancetype)mgl_expressionForAttributedExpressions: + (nonnull NSArray *)attributedExpressions + NS_SWIFT_NAME(init(forAttributedExpressions:)); // MARK: Concatenating String Expressions /** Returns a constant expression appending the passed expression. - + @note Both the receiver and the given expression must be an `NSString` constant expression type; otherwise, an exception is rised. - + @param expression The expression to append to the receiver. */ -- (instancetype)mgl_expressionByAppendingExpression:(nonnull NSExpression *)expression NS_SWIFT_NAME(mgl_appending(_:)); +- (instancetype)mgl_expressionByAppendingExpression:(nonnull NSExpression *)expression + NS_SWIFT_NAME(mgl_appending(_:)); // MARK: Converting JSON Expressions /** Returns an expression equivalent to the given Foundation object deserialized from JSON data. - + The Foundation object is interpreted according to the [MapLibre Style Spec](https://maplibre.org/maplibre-style-spec/expressions/). See the “[Information for Style Authors](../for-style-authors.html#setting-attribute-values)” guide for a correspondence of operators and types between the style specification and the `NSExpression` representation used by this SDK. - + @param object A Foundation object deserialized from JSON data, for example using `NSJSONSerialization`. @return An initialized expression equivalent to `object`, suitable for use as @@ -199,14 +229,14 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI /** An equivalent Foundation object that can be serialized as JSON. - + The Foundation object conforms to the [MapLibre Style Spec](https://maplibre.org/maplibre-style-spec/expressions/). See the “[Information for Style Authors](../for-style-authors.html#setting-attribute-values)” guide for a correspondence of operators and types between the style specification and the `NSExpression` representation used by this SDK. - + You can use `NSJSONSerialization` to serialize the Foundation object as data to write to a file. */ @@ -216,14 +246,14 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI /** Returns a copy of the receiver localized into the given locale. - + This method assumes the receiver refers to the feature attributes that are available in vector tiles supplied by the - Mapbox Streets source. - On iOS, the user can set the system’s preferred language in Settings, General - Settings, Language & Region. On macOS, the user can set the system’s preferred - language in the Language & Region pane of System Preferences. - + Mapbox Streets + source. On iOS, the user can set the system’s preferred language in Settings, General Settings, + Language & Region. On macOS, the user can set the system’s preferred language in the Language & + Region pane of System Preferences. + @param locale The locale into which labels should be localized. To use the system’s preferred language, if supported, specify `nil`. To use the local language, specify a locale with the identifier `mul`. diff --git a/platform/darwin/src/NSExpression+MLNPrivateAdditions.h b/platform/darwin/src/NSExpression+MLNPrivateAdditions.h index 651e1e983..81e538799 100644 --- a/platform/darwin/src/NSExpression+MLNPrivateAdditions.h +++ b/platform/darwin/src/NSExpression+MLNPrivateAdditions.h @@ -1,8 +1,8 @@ #import #if TARGET_OS_IPHONE - #import +#import #else - #import +#import #endif #import "NSExpression+MLNAdditions.h" @@ -14,7 +14,8 @@ NS_ASSUME_NONNULL_BEGIN @interface NSObject (MLNExpressionAdditions) - (nullable NSNumber *)mgl_number; -- (nullable NSNumber *)mgl_numberWithFallbackValues:(id)fallbackValue, ... NS_REQUIRES_NIL_TERMINATION; +- (nullable NSNumber *)mgl_numberWithFallbackValues:(id)fallbackValue, + ... NS_REQUIRES_NIL_TERMINATION; @end @@ -43,7 +44,9 @@ NS_ASSUME_NONNULL_BEGIN @interface NSNumber (MLNExpressionAdditions) -- (id)mgl_interpolateWithCurveType:(NSString *)curveType parameters:(NSArray *)parameters stops:(NSDictionary *)stops; +- (id)mgl_interpolateWithCurveType:(NSString *)curveType + parameters:(NSArray *)parameters + stops:(NSDictionary *)stops; - (id)mgl_stepWithMinimum:(id)minimum stops:(NSDictionary *)stops; @property (nonatomic, readonly) id mgl_jsonExpressionObject; @@ -74,7 +77,6 @@ NS_ASSUME_NONNULL_BEGIN - (NSExpression *)mgl_expressionWithContext:(NSDictionary *)context; - - (id)mgl_has:(id)element; @end diff --git a/platform/darwin/src/NSPredicate+MLNAdditions.h b/platform/darwin/src/NSPredicate+MLNAdditions.h index 6bf639ea2..e6edbacbd 100644 --- a/platform/darwin/src/NSPredicate+MLNAdditions.h +++ b/platform/darwin/src/NSPredicate+MLNAdditions.h @@ -9,14 +9,14 @@ NS_ASSUME_NONNULL_BEGIN /** Returns a predicate equivalent to the given Foundation object deserialized from JSON data. - + The Foundation object is interpreted according to the [MapLibre Style Spec](https://maplibre.org/maplibre-style-spec/expressions/). See the “[Predicates and Expressions](../predicates-and-expressions.html)” guide for a correspondence of operators and types between the style specification and the `NSPredicate` representation used by this SDK. - + @param object A Foundation object deserialized from JSON data, for example using `NSJSONSerialization`. @return An initialized predicate equivalent to `object`, suitable for use @@ -26,14 +26,14 @@ NS_ASSUME_NONNULL_BEGIN /** An equivalent Foundation object that can be serialized as JSON. - + The Foundation object conforms to the [MapLibre Style Spec](https://maplibre.org/maplibre-style-spec/expressions/). See the “[Predicates and Expressions](../predicates-and-expressions.html)” guide for a correspondence of operators and types between the style specification and the `NSPredicate` representation used by this SDK. - + You can use `NSJSONSerialization` to serialize the Foundation object as data to write to a file. */ diff --git a/platform/darwin/src/NSValue+MLNAdditions.h b/platform/darwin/src/NSValue+MLNAdditions.h index c1baedcdf..9ff35a353 100644 --- a/platform/darwin/src/NSValue+MLNAdditions.h +++ b/platform/darwin/src/NSValue+MLNAdditions.h @@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN @property (readonly) MLNCoordinateBounds MLNCoordinateBoundsValue; /** - Creates a new value object containing the specified Mapbox coordinate + Creates a new value object containing the specified Mapbox coordinate quad structure. @param quad The value for the new object. @@ -104,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN /** Creates a new value object containing the given `MLNTransition` structure. - + @param transition The value for the new object. @return A new value object that contains the transition information. */ @@ -118,7 +118,7 @@ NS_ASSUME_NONNULL_BEGIN /** Creates a new value object containing the given `MLNSphericalPosition` structure. - + @param lightPosition The value for the new object. @return A new value object that contains the light position information. */ @@ -132,7 +132,7 @@ NS_ASSUME_NONNULL_BEGIN /** Creates a new value object containing the given `MLNLightAnchor` enum. - + @param lightAnchor The value for the new object. @return A new value object that contains the light anchor information. */ diff --git a/platform/darwin/src/async_task.cpp b/platform/darwin/src/async_task.cpp index 48457d24a..26fb86d73 100644 --- a/platform/darwin/src/async_task.cpp +++ b/platform/darwin/src/async_task.cpp @@ -13,17 +13,7 @@ public: : task(std::move(fn)), loop(CFRunLoopGetCurrent()) { CFRunLoopSourceContext context = { - 0, - this, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - perform - }; + 0, this, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, perform}; source = CFRunLoopSourceCreate(kCFAllocatorDefault, 0, &context); CFRunLoopAddSource(loop, source, kCFRunLoopCommonModes); } @@ -46,9 +36,7 @@ public: } private: - static void perform(void* info) { - reinterpret_cast(info)->runTask(); - } + static void perform(void* info) { reinterpret_cast(info)->runTask(); } std::function task; std::atomic_flag queued = ATOMIC_FLAG_INIT; @@ -58,8 +46,7 @@ private: }; AsyncTask::AsyncTask(std::function&& fn) - : impl(std::make_unique(std::move(fn))) { -} + : impl(std::make_unique(std::move(fn))) {} AsyncTask::~AsyncTask() = default; diff --git a/platform/darwin/src/gl_functions.cpp b/platform/darwin/src/gl_functions.cpp index 1e9d2a668..5050214eb 100644 --- a/platform/darwin/src/gl_functions.cpp +++ b/platform/darwin/src/gl_functions.cpp @@ -3,17 +3,17 @@ #include "TargetConditionals.h" #if TARGET_OS_IPHONE - #include - #include +#include +#include #elif TARGET_OS_SIMULATOR - #include - #include +#include +#include #elif TARGET_OS_MAC - #include - #include - #include +#include +#include +#include #else - #error Unsupported Apple platform +#error Unsupported Apple platform #endif namespace mbgl { @@ -21,258 +21,276 @@ namespace platform { /* OpenGL ES 2.0 */ -void (* const glActiveTexture)(GLenum) = ::glActiveTexture; -void (* const glAttachShader)(GLuint, GLuint) = ::glAttachShader; -void (* const glBindAttribLocation)(GLuint, GLuint, const GLchar *) = ::glBindAttribLocation; -void (* const glBindBuffer)(GLenum, GLuint) = ::glBindBuffer; -void (* const glBindFramebuffer)(GLenum, GLuint) = ::glBindFramebuffer; -void (* const glBindRenderbuffer)(GLenum, GLuint) = ::glBindRenderbuffer; -void (* const glBindTexture)(GLenum, GLuint) = ::glBindTexture; -void (* const glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = ::glBlendColor; -void (* const glBlendEquation)(GLenum) = ::glBlendEquation; -void (* const glBlendEquationSeparate)(GLenum, GLenum) = ::glBlendEquationSeparate; -void (* const glBlendFunc)(GLenum, GLenum) = ::glBlendFunc; -void (* const glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = ::glBlendFuncSeparate; -void (* const glBufferData)(GLenum, GLsizeiptr, const void *, GLenum) = ::glBufferData; -void (* const glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const void *) = ::glBufferSubData; -GLenum (* const glCheckFramebufferStatus)(GLenum) = ::glCheckFramebufferStatus; -void (* const glClear)(GLbitfield) = ::glClear; -void (* const glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = ::glClearColor; -void (* const glClearDepthf)(GLfloat) = ::glClearDepthf; -void (* const glClearStencil)(GLint) = ::glClearStencil; -void (* const glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = ::glColorMask; -void (* const glCompileShader)(GLuint) = ::glCompileShader; -void (* const glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *) = ::glCompressedTexImage2D; -void (* const glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *) = ::glCompressedTexSubImage2D; -void (* const glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = ::glCopyTexImage2D; -void (* const glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = ::glCopyTexSubImage2D; -GLuint (* const glCreateProgram)() = ::glCreateProgram; -GLuint (* const glCreateShader)(GLenum) = ::glCreateShader; -void (* const glCullFace)(GLenum) = ::glCullFace; -void (* const glDeleteBuffers)(GLsizei, const GLuint *) = ::glDeleteBuffers; -void (* const glDeleteFramebuffers)(GLsizei, const GLuint *) = ::glDeleteFramebuffers; -void (* const glDeleteProgram)(GLuint) = ::glDeleteProgram; -void (* const glDeleteRenderbuffers)(GLsizei, const GLuint *) = ::glDeleteRenderbuffers; -void (* const glDeleteShader)(GLuint) = ::glDeleteShader; -void (* const glDeleteTextures)(GLsizei, const GLuint *) = ::glDeleteTextures; -void (* const glDepthFunc)(GLenum) = ::glDepthFunc; -void (* const glDepthMask)(GLboolean) = ::glDepthMask; -void (* const glDepthRangef)(GLfloat, GLfloat) = ::glDepthRangef; -void (* const glDetachShader)(GLuint, GLuint) = ::glDetachShader; -void (* const glDisable)(GLenum) = ::glDisable; -void (* const glDisableVertexAttribArray)(GLuint) = ::glDisableVertexAttribArray; -void (* const glDrawArrays)(GLenum, GLint, GLsizei) = ::glDrawArrays; -void (* const glDrawElements)(GLenum, GLsizei, GLenum, const void *) = ::glDrawElements; -void (* const glEnable)(GLenum) = ::glEnable; -void (* const glEnableVertexAttribArray)(GLuint) = ::glEnableVertexAttribArray; -void (* const glFinish)() = ::glFinish; -void (* const glFlush)() = ::glFlush; -void (* const glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = ::glFramebufferRenderbuffer; -void (* const glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = ::glFramebufferTexture2D; -void (* const glFrontFace)(GLenum) = ::glFrontFace; -void (* const glGenBuffers)(GLsizei, GLuint *) = ::glGenBuffers; -void (* const glGenerateMipmap)(GLenum) = ::glGenerateMipmap; -void (* const glGenFramebuffers)(GLsizei, GLuint *) = ::glGenFramebuffers; -void (* const glGenRenderbuffers)(GLsizei, GLuint *) = ::glGenRenderbuffers; -void (* const glGenTextures)(GLsizei, GLuint *) = ::glGenTextures; -void (* const glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = ::glGetActiveAttrib; -void (* const glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = ::glGetActiveUniform; -void (* const glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *) = ::glGetAttachedShaders; -GLint (* const glGetAttribLocation)(GLuint, const GLchar *) = ::glGetAttribLocation; -void (* const glGetBooleanv)(GLenum, GLboolean *) = ::glGetBooleanv; -void (* const glGetBufferParameteriv)(GLenum, GLenum, GLint *) = ::glGetBufferParameteriv; -GLenum (* const glGetError)() = ::glGetError; -void (* const glGetFloatv)(GLenum, GLfloat *) = ::glGetFloatv; -void (* const glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *) = ::glGetFramebufferAttachmentParameteriv; -void (* const glGetIntegerv)(GLenum, GLint *) = ::glGetIntegerv; -void (* const glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = ::glGetProgramInfoLog; -void (* const glGetProgramiv)(GLuint, GLenum, GLint *) = ::glGetProgramiv; -void (* const glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *) = ::glGetRenderbufferParameteriv; -void (* const glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = ::glGetShaderInfoLog; -void (* const glGetShaderiv)(GLuint, GLenum, GLint *) = ::glGetShaderiv; -void (* const glGetShaderPrecisionFormat)(GLenum, GLenum, GLint *, GLint *) = ::glGetShaderPrecisionFormat; -void (* const glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *) = ::glGetShaderSource; -const GLubyte *(* const glGetString)(GLenum) = ::glGetString; -void (* const glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = ::glGetTexParameterfv; -void (* const glGetTexParameteriv)(GLenum, GLenum, GLint *) = ::glGetTexParameteriv; -void (* const glGetUniformfv)(GLuint, GLint, GLfloat *) = ::glGetUniformfv; -void (* const glGetUniformiv)(GLuint, GLint, GLint *) = ::glGetUniformiv; -GLint (* const glGetUniformLocation)(GLuint, const GLchar *) = ::glGetUniformLocation; -void (* const glGetVertexAttribfv)(GLuint, GLenum, GLfloat *) = ::glGetVertexAttribfv; -void (* const glGetVertexAttribiv)(GLuint, GLenum, GLint *) = ::glGetVertexAttribiv; -void (* const glGetVertexAttribPointerv)(GLuint, GLenum, void **) = ::glGetVertexAttribPointerv; -void (* const glHint)(GLenum, GLenum) = ::glHint; -GLboolean (* const glIsBuffer)(GLuint) = ::glIsBuffer; -GLboolean (* const glIsEnabled)(GLenum) = ::glIsEnabled; -GLboolean (* const glIsFramebuffer)(GLuint) = ::glIsFramebuffer; -GLboolean (* const glIsProgram)(GLuint) = ::glIsProgram; -GLboolean (* const glIsRenderbuffer)(GLuint) = ::glIsRenderbuffer; -GLboolean (* const glIsShader)(GLuint) = ::glIsShader; -GLboolean (* const glIsTexture)(GLuint) = ::glIsTexture; -void (* const glLineWidth)(GLfloat) = ::glLineWidth; -void (* const glLinkProgram)(GLuint) = ::glLinkProgram; -void (* const glPixelStorei)(GLenum, GLint) = ::glPixelStorei; -void (* const glPolygonOffset)(GLfloat, GLfloat) = ::glPolygonOffset; -void (* const glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *) = ::glReadPixels; -void (* const glReleaseShaderCompiler)() = ::glReleaseShaderCompiler; -void (* const glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = ::glRenderbufferStorage; -void (* const glSampleCoverage)(GLfloat, GLboolean) = ::glSampleCoverage; -void (* const glScissor)(GLint, GLint, GLsizei, GLsizei) = ::glScissor; -void (* const glShaderBinary)(GLsizei, const GLuint *, GLenum, const GLvoid *, GLsizei) = ::glShaderBinary; -void (* const glShaderSource)(GLuint, GLsizei, const GLchar * const*, const GLint *) = ::glShaderSource; -void (* const glStencilFunc)(GLenum, GLint, GLuint) = ::glStencilFunc; -void (* const glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = ::glStencilFuncSeparate; -void (* const glStencilMask)(GLuint) = ::glStencilMask; -void (* const glStencilMaskSeparate)(GLenum, GLuint) = ::glStencilMaskSeparate; -void (* const glStencilOp)(GLenum, GLenum, GLenum) = ::glStencilOp; -void (* const glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = ::glStencilOpSeparate; -void (* const glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *) = ::glTexImage2D; -void (* const glTexParameterf)(GLenum, GLenum, GLfloat) = ::glTexParameterf; -void (* const glTexParameterfv)(GLenum, GLenum, const GLfloat *) = ::glTexParameterfv; -void (* const glTexParameteri)(GLenum, GLenum, GLint) = ::glTexParameteri; -void (* const glTexParameteriv)(GLenum, GLenum, const GLint *) = ::glTexParameteriv; -void (* const glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *) = ::glTexSubImage2D; -void (* const glUniform1f)(GLint, GLfloat) = ::glUniform1f; -void (* const glUniform1fv)(GLint, GLsizei, const GLfloat *) = ::glUniform1fv; -void (* const glUniform1i)(GLint, GLint) = ::glUniform1i; -void (* const glUniform1iv)(GLint, GLsizei, const GLint *) = ::glUniform1iv; -void (* const glUniform2f)(GLint, GLfloat, GLfloat) = ::glUniform2f; -void (* const glUniform2fv)(GLint, GLsizei, const GLfloat *) = ::glUniform2fv; -void (* const glUniform2i)(GLint, GLint, GLint) = ::glUniform2i; -void (* const glUniform2iv)(GLint, GLsizei, const GLint *) = ::glUniform2iv; -void (* const glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = ::glUniform3f; -void (* const glUniform3fv)(GLint, GLsizei, const GLfloat *) = ::glUniform3fv; -void (* const glUniform3i)(GLint, GLint, GLint, GLint) = ::glUniform3i; -void (* const glUniform3iv)(GLint, GLsizei, const GLint *) = ::glUniform3iv; -void (* const glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = ::glUniform4f; -void (* const glUniform4fv)(GLint, GLsizei, const GLfloat *) = ::glUniform4fv; -void (* const glUniform4i)(GLint, GLint, GLint, GLint, GLint) = ::glUniform4i; -void (* const glUniform4iv)(GLint, GLsizei, const GLint *) = ::glUniform4iv; -void (* const glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix2fv; -void (* const glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix3fv; -void (* const glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix4fv; -void (* const glUseProgram)(GLuint) = ::glUseProgram; -void (* const glValidateProgram)(GLuint) = ::glValidateProgram; -void (* const glVertexAttrib1f)(GLuint, GLfloat) = ::glVertexAttrib1f; -void (* const glVertexAttrib1fv)(GLuint, const GLfloat *) = ::glVertexAttrib1fv; -void (* const glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = ::glVertexAttrib2f; -void (* const glVertexAttrib2fv)(GLuint, const GLfloat *) = ::glVertexAttrib2fv; -void (* const glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = ::glVertexAttrib3f; -void (* const glVertexAttrib3fv)(GLuint, const GLfloat *) = ::glVertexAttrib3fv; -void (* const glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = ::glVertexAttrib4f; -void (* const glVertexAttrib4fv)(GLuint, const GLfloat *) = ::glVertexAttrib4fv; -void (* const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void *) = ::glVertexAttribPointer; -void (* const glViewport)(GLint, GLint, GLsizei, GLsizei) = ::glViewport; +void (*const glActiveTexture)(GLenum) = ::glActiveTexture; +void (*const glAttachShader)(GLuint, GLuint) = ::glAttachShader; +void (*const glBindAttribLocation)(GLuint, GLuint, const GLchar*) = ::glBindAttribLocation; +void (*const glBindBuffer)(GLenum, GLuint) = ::glBindBuffer; +void (*const glBindFramebuffer)(GLenum, GLuint) = ::glBindFramebuffer; +void (*const glBindRenderbuffer)(GLenum, GLuint) = ::glBindRenderbuffer; +void (*const glBindTexture)(GLenum, GLuint) = ::glBindTexture; +void (*const glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = ::glBlendColor; +void (*const glBlendEquation)(GLenum) = ::glBlendEquation; +void (*const glBlendEquationSeparate)(GLenum, GLenum) = ::glBlendEquationSeparate; +void (*const glBlendFunc)(GLenum, GLenum) = ::glBlendFunc; +void (*const glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = ::glBlendFuncSeparate; +void (*const glBufferData)(GLenum, GLsizeiptr, const void*, GLenum) = ::glBufferData; +void (*const glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const void*) = ::glBufferSubData; +GLenum (*const glCheckFramebufferStatus)(GLenum) = ::glCheckFramebufferStatus; +void (*const glClear)(GLbitfield) = ::glClear; +void (*const glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = ::glClearColor; +void (*const glClearDepthf)(GLfloat) = ::glClearDepthf; +void (*const glClearStencil)(GLint) = ::glClearStencil; +void (*const glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = ::glColorMask; +void (*const glCompileShader)(GLuint) = ::glCompileShader; +void (*const glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void*) = + ::glCompressedTexImage2D; +void (*const glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void*) = + ::glCompressedTexSubImage2D; +void (*const glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = ::glCopyTexImage2D; +void (*const glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = ::glCopyTexSubImage2D; +GLuint (*const glCreateProgram)() = ::glCreateProgram; +GLuint (*const glCreateShader)(GLenum) = ::glCreateShader; +void (*const glCullFace)(GLenum) = ::glCullFace; +void (*const glDeleteBuffers)(GLsizei, const GLuint*) = ::glDeleteBuffers; +void (*const glDeleteFramebuffers)(GLsizei, const GLuint*) = ::glDeleteFramebuffers; +void (*const glDeleteProgram)(GLuint) = ::glDeleteProgram; +void (*const glDeleteRenderbuffers)(GLsizei, const GLuint*) = ::glDeleteRenderbuffers; +void (*const glDeleteShader)(GLuint) = ::glDeleteShader; +void (*const glDeleteTextures)(GLsizei, const GLuint*) = ::glDeleteTextures; +void (*const glDepthFunc)(GLenum) = ::glDepthFunc; +void (*const glDepthMask)(GLboolean) = ::glDepthMask; +void (*const glDepthRangef)(GLfloat, GLfloat) = ::glDepthRangef; +void (*const glDetachShader)(GLuint, GLuint) = ::glDetachShader; +void (*const glDisable)(GLenum) = ::glDisable; +void (*const glDisableVertexAttribArray)(GLuint) = ::glDisableVertexAttribArray; +void (*const glDrawArrays)(GLenum, GLint, GLsizei) = ::glDrawArrays; +void (*const glDrawElements)(GLenum, GLsizei, GLenum, const void*) = ::glDrawElements; +void (*const glEnable)(GLenum) = ::glEnable; +void (*const glEnableVertexAttribArray)(GLuint) = ::glEnableVertexAttribArray; +void (*const glFinish)() = ::glFinish; +void (*const glFlush)() = ::glFlush; +void (*const glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = ::glFramebufferRenderbuffer; +void (*const glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = ::glFramebufferTexture2D; +void (*const glFrontFace)(GLenum) = ::glFrontFace; +void (*const glGenBuffers)(GLsizei, GLuint*) = ::glGenBuffers; +void (*const glGenerateMipmap)(GLenum) = ::glGenerateMipmap; +void (*const glGenFramebuffers)(GLsizei, GLuint*) = ::glGenFramebuffers; +void (*const glGenRenderbuffers)(GLsizei, GLuint*) = ::glGenRenderbuffers; +void (*const glGenTextures)(GLsizei, GLuint*) = ::glGenTextures; +void (*const glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*) = ::glGetActiveAttrib; +void (*const glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*) = ::glGetActiveUniform; +void (*const glGetAttachedShaders)(GLuint, GLsizei, GLsizei*, GLuint*) = ::glGetAttachedShaders; +GLint (*const glGetAttribLocation)(GLuint, const GLchar*) = ::glGetAttribLocation; +void (*const glGetBooleanv)(GLenum, GLboolean*) = ::glGetBooleanv; +void (*const glGetBufferParameteriv)(GLenum, GLenum, GLint*) = ::glGetBufferParameteriv; +GLenum (*const glGetError)() = ::glGetError; +void (*const glGetFloatv)(GLenum, GLfloat*) = ::glGetFloatv; +void (*const glGetFramebufferAttachmentParameteriv)(GLenum, + GLenum, + GLenum, + GLint*) = ::glGetFramebufferAttachmentParameteriv; +void (*const glGetIntegerv)(GLenum, GLint*) = ::glGetIntegerv; +void (*const glGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*) = ::glGetProgramInfoLog; +void (*const glGetProgramiv)(GLuint, GLenum, GLint*) = ::glGetProgramiv; +void (*const glGetRenderbufferParameteriv)(GLenum, GLenum, GLint*) = ::glGetRenderbufferParameteriv; +void (*const glGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*) = ::glGetShaderInfoLog; +void (*const glGetShaderiv)(GLuint, GLenum, GLint*) = ::glGetShaderiv; +void (*const glGetShaderPrecisionFormat)(GLenum, GLenum, GLint*, GLint*) = ::glGetShaderPrecisionFormat; +void (*const glGetShaderSource)(GLuint, GLsizei, GLsizei*, GLchar*) = ::glGetShaderSource; +const GLubyte* (*const glGetString)(GLenum) = ::glGetString; +void (*const glGetTexParameterfv)(GLenum, GLenum, GLfloat*) = ::glGetTexParameterfv; +void (*const glGetTexParameteriv)(GLenum, GLenum, GLint*) = ::glGetTexParameteriv; +void (*const glGetUniformfv)(GLuint, GLint, GLfloat*) = ::glGetUniformfv; +void (*const glGetUniformiv)(GLuint, GLint, GLint*) = ::glGetUniformiv; +GLint (*const glGetUniformLocation)(GLuint, const GLchar*) = ::glGetUniformLocation; +void (*const glGetVertexAttribfv)(GLuint, GLenum, GLfloat*) = ::glGetVertexAttribfv; +void (*const glGetVertexAttribiv)(GLuint, GLenum, GLint*) = ::glGetVertexAttribiv; +void (*const glGetVertexAttribPointerv)(GLuint, GLenum, void**) = ::glGetVertexAttribPointerv; +void (*const glHint)(GLenum, GLenum) = ::glHint; +GLboolean (*const glIsBuffer)(GLuint) = ::glIsBuffer; +GLboolean (*const glIsEnabled)(GLenum) = ::glIsEnabled; +GLboolean (*const glIsFramebuffer)(GLuint) = ::glIsFramebuffer; +GLboolean (*const glIsProgram)(GLuint) = ::glIsProgram; +GLboolean (*const glIsRenderbuffer)(GLuint) = ::glIsRenderbuffer; +GLboolean (*const glIsShader)(GLuint) = ::glIsShader; +GLboolean (*const glIsTexture)(GLuint) = ::glIsTexture; +void (*const glLineWidth)(GLfloat) = ::glLineWidth; +void (*const glLinkProgram)(GLuint) = ::glLinkProgram; +void (*const glPixelStorei)(GLenum, GLint) = ::glPixelStorei; +void (*const glPolygonOffset)(GLfloat, GLfloat) = ::glPolygonOffset; +void (*const glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void*) = ::glReadPixels; +void (*const glReleaseShaderCompiler)() = ::glReleaseShaderCompiler; +void (*const glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = ::glRenderbufferStorage; +void (*const glSampleCoverage)(GLfloat, GLboolean) = ::glSampleCoverage; +void (*const glScissor)(GLint, GLint, GLsizei, GLsizei) = ::glScissor; +void (*const glShaderBinary)(GLsizei, const GLuint*, GLenum, const GLvoid*, GLsizei) = ::glShaderBinary; +void (*const glShaderSource)(GLuint, GLsizei, const GLchar* const*, const GLint*) = ::glShaderSource; +void (*const glStencilFunc)(GLenum, GLint, GLuint) = ::glStencilFunc; +void (*const glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = ::glStencilFuncSeparate; +void (*const glStencilMask)(GLuint) = ::glStencilMask; +void (*const glStencilMaskSeparate)(GLenum, GLuint) = ::glStencilMaskSeparate; +void (*const glStencilOp)(GLenum, GLenum, GLenum) = ::glStencilOp; +void (*const glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = ::glStencilOpSeparate; +void (*const glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*) = ::glTexImage2D; +void (*const glTexParameterf)(GLenum, GLenum, GLfloat) = ::glTexParameterf; +void (*const glTexParameterfv)(GLenum, GLenum, const GLfloat*) = ::glTexParameterfv; +void (*const glTexParameteri)(GLenum, GLenum, GLint) = ::glTexParameteri; +void (*const glTexParameteriv)(GLenum, GLenum, const GLint*) = ::glTexParameteriv; +void (*const glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void*) = + ::glTexSubImage2D; +void (*const glUniform1f)(GLint, GLfloat) = ::glUniform1f; +void (*const glUniform1fv)(GLint, GLsizei, const GLfloat*) = ::glUniform1fv; +void (*const glUniform1i)(GLint, GLint) = ::glUniform1i; +void (*const glUniform1iv)(GLint, GLsizei, const GLint*) = ::glUniform1iv; +void (*const glUniform2f)(GLint, GLfloat, GLfloat) = ::glUniform2f; +void (*const glUniform2fv)(GLint, GLsizei, const GLfloat*) = ::glUniform2fv; +void (*const glUniform2i)(GLint, GLint, GLint) = ::glUniform2i; +void (*const glUniform2iv)(GLint, GLsizei, const GLint*) = ::glUniform2iv; +void (*const glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = ::glUniform3f; +void (*const glUniform3fv)(GLint, GLsizei, const GLfloat*) = ::glUniform3fv; +void (*const glUniform3i)(GLint, GLint, GLint, GLint) = ::glUniform3i; +void (*const glUniform3iv)(GLint, GLsizei, const GLint*) = ::glUniform3iv; +void (*const glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = ::glUniform4f; +void (*const glUniform4fv)(GLint, GLsizei, const GLfloat*) = ::glUniform4fv; +void (*const glUniform4i)(GLint, GLint, GLint, GLint, GLint) = ::glUniform4i; +void (*const glUniform4iv)(GLint, GLsizei, const GLint*) = ::glUniform4iv; +void (*const glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix2fv; +void (*const glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix3fv; +void (*const glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix4fv; +void (*const glUseProgram)(GLuint) = ::glUseProgram; +void (*const glValidateProgram)(GLuint) = ::glValidateProgram; +void (*const glVertexAttrib1f)(GLuint, GLfloat) = ::glVertexAttrib1f; +void (*const glVertexAttrib1fv)(GLuint, const GLfloat*) = ::glVertexAttrib1fv; +void (*const glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = ::glVertexAttrib2f; +void (*const glVertexAttrib2fv)(GLuint, const GLfloat*) = ::glVertexAttrib2fv; +void (*const glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = ::glVertexAttrib3f; +void (*const glVertexAttrib3fv)(GLuint, const GLfloat*) = ::glVertexAttrib3fv; +void (*const glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = ::glVertexAttrib4f; +void (*const glVertexAttrib4fv)(GLuint, const GLfloat*) = ::glVertexAttrib4fv; +void (*const glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*) = ::glVertexAttribPointer; +void (*const glViewport)(GLint, GLint, GLsizei, GLsizei) = ::glViewport; /* OpenGL ES 3.0 */ -void (* const glReadBuffer)(GLenum) = ::glReadBuffer; -void (* const glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *) = ::glDrawRangeElements; -void (* const glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = ::glTexImage3D; -void (* const glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = ::glTexSubImage3D; -void (* const glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = ::glCopyTexSubImage3D; -void (* const glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = ::glCompressedTexImage3D; -void (* const glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = ::glCompressedTexSubImage3D; -void (* const glGenQueries)(GLsizei, GLuint *) = ::glGenQueries; -void (* const glDeleteQueries)(GLsizei, const GLuint *) = ::glDeleteQueries; -GLboolean (* const glIsQuery)(GLuint) = ::glIsQuery; -void (* const glBeginQuery)(GLenum, GLuint) = ::glBeginQuery; -void (* const glEndQuery)(GLenum) = ::glEndQuery; -void (* const glGetQueryiv)(GLenum, GLenum, GLint *) = ::glGetQueryiv; -void (* const glGetQueryObjectuiv)(GLuint, GLenum, GLuint *) = ::glGetQueryObjectuiv; -GLboolean (* const glUnmapBuffer)(GLenum) = ::glUnmapBuffer; -void (* const glGetBufferPointerv)(GLenum, GLenum, GLvoid **) = ::glGetBufferPointerv; -void (* const glDrawBuffers)(GLsizei, const GLenum *) = ::glDrawBuffers; -void (* const glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix2x3fv; -void (* const glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix3x2fv; -void (* const glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix2x4fv; -void (* const glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix4x2fv; -void (* const glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix3x4fv; -void (* const glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = ::glUniformMatrix4x3fv; -void (* const glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = ::glBlitFramebuffer; -void (* const glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = ::glRenderbufferStorageMultisample; -void (* const glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = ::glFramebufferTextureLayer; -GLvoid* (* const glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = ::glMapBufferRange; -void (* const glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = ::glFlushMappedBufferRange; -void (* const glBindVertexArray)(GLuint) = ::glBindVertexArray; -void (* const glDeleteVertexArrays)(GLsizei, const GLuint *) = ::glDeleteVertexArrays; -void (* const glGenVertexArrays)(GLsizei, GLuint *) = ::glGenVertexArrays; -GLboolean (* const glIsVertexArray)(GLuint) = ::glIsVertexArray; -void (* const glGetIntegeri_v)(GLenum, GLuint, GLint *) = ::glGetIntegeri_v; -void (* const glBeginTransformFeedback)(GLenum) = ::glBeginTransformFeedback; -void (* const glEndTransformFeedback)() = ::glEndTransformFeedback; -void (* const glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = ::glBindBufferRange; -void (* const glBindBufferBase)(GLenum, GLuint, GLuint) = ::glBindBufferBase; -void (* const glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar * const*, GLenum) = ::glTransformFeedbackVaryings; -void (* const glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *) = ::glGetTransformFeedbackVarying; -void (* const glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *) = ::glVertexAttribIPointer; -void (* const glGetVertexAttribIiv)(GLuint, GLenum, GLint *) = ::glGetVertexAttribIiv; -void (* const glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *) = ::glGetVertexAttribIuiv; -void (* const glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = ::glVertexAttribI4i; -void (* const glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = ::glVertexAttribI4ui; -void (* const glVertexAttribI4iv)(GLuint, const GLint *) = ::glVertexAttribI4iv; -void (* const glVertexAttribI4uiv)(GLuint, const GLuint *) = ::glVertexAttribI4uiv; -void (* const glGetUniformuiv)(GLuint, GLint, GLuint *) = ::glGetUniformuiv; -GLint (* const glGetFragDataLocation)(GLuint, const GLchar *) = ::glGetFragDataLocation; -void (* const glUniform1ui)(GLint, GLuint) = ::glUniform1ui; -void (* const glUniform2ui)(GLint, GLuint, GLuint) = ::glUniform2ui; -void (* const glUniform3ui)(GLint, GLuint, GLuint, GLuint) = ::glUniform3ui; -void (* const glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = ::glUniform4ui; -void (* const glUniform1uiv)(GLint, GLsizei, const GLuint *) = ::glUniform1uiv; -void (* const glUniform2uiv)(GLint, GLsizei, const GLuint *) = ::glUniform2uiv; -void (* const glUniform3uiv)(GLint, GLsizei, const GLuint *) = ::glUniform3uiv; -void (* const glUniform4uiv)(GLint, GLsizei, const GLuint *) = ::glUniform4uiv; -void (* const glClearBufferiv)(GLenum, GLint, const GLint *) = ::glClearBufferiv; -void (* const glClearBufferuiv)(GLenum, GLint, const GLuint *) = ::glClearBufferuiv; -void (* const glClearBufferfv)(GLenum, GLint, const GLfloat *) = ::glClearBufferfv; -void (* const glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = ::glClearBufferfi; -const GLubyte* (* const glGetStringi)(GLenum, GLuint) = ::glGetStringi; -void (* const glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = ::glCopyBufferSubData; -void (* const glGetUniformIndices)(GLuint, GLsizei, const GLchar * const*, GLuint *) = ::glGetUniformIndices; -void (* const glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *) = ::glGetActiveUniformsiv; -GLuint (* const glGetUniformBlockIndex)(GLuint, const GLchar *) = ::glGetUniformBlockIndex; -void (* const glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *) = ::glGetActiveUniformBlockiv; -void (* const glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = ::glGetActiveUniformBlockName; -void (* const glUniformBlockBinding)(GLuint, GLuint, GLuint) = ::glUniformBlockBinding; -void (* const glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = ::glDrawArraysInstanced; -void (* const glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei) = ::glDrawElementsInstanced; -GLsync (* const glFenceSync)(GLenum, GLbitfield) = ::glFenceSync; -GLboolean (* const glIsSync)(GLsync) = ::glIsSync; -void (* const glDeleteSync)(GLsync) = ::glDeleteSync; -GLenum (* const glClientWaitSync)(GLsync, GLbitfield, GLuint64) = ::glClientWaitSync; -void (* const glWaitSync)(GLsync, GLbitfield, GLuint64) = ::glWaitSync; -void (* const glGetInteger64v)(GLenum, GLint64 *) = ::glGetInteger64v; -void (* const glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *) = ::glGetSynciv; -void (* const glGetInteger64i_v)(GLenum, GLuint, GLint64 *) = ::glGetInteger64i_v; -void (* const glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *) = ::glGetBufferParameteri64v; -void (* const glGenSamplers)(GLsizei, GLuint *) = ::glGenSamplers; -void (* const glDeleteSamplers)(GLsizei, const GLuint *) = ::glDeleteSamplers; -GLboolean (* const glIsSampler)(GLuint) = ::glIsSampler; -void (* const glBindSampler)(GLuint, GLuint) = ::glBindSampler; -void (* const glSamplerParameteri)(GLuint, GLenum, GLint) = ::glSamplerParameteri; -void (* const glSamplerParameteriv)(GLuint, GLenum, const GLint *) = ::glSamplerParameteriv; -void (* const glSamplerParameterf)(GLuint, GLenum, GLfloat) = ::glSamplerParameterf; -void (* const glSamplerParameterfv)(GLuint, GLenum, const GLfloat *) = ::glSamplerParameterfv; -void (* const glGetSamplerParameteriv)(GLuint, GLenum, GLint *) = ::glGetSamplerParameteriv; -void (* const glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *) = ::glGetSamplerParameterfv; -void (* const glVertexAttribDivisor)(GLuint, GLuint) = ::glVertexAttribDivisor; -void (* const glBindTransformFeedback)(GLenum, GLuint) = ::glBindTransformFeedback; -void (* const glDeleteTransformFeedbacks)(GLsizei, const GLuint *) = ::glDeleteTransformFeedbacks; -void (* const glGenTransformFeedbacks)(GLsizei, GLuint *) = ::glGenTransformFeedbacks; -GLboolean (* const glIsTransformFeedback)(GLuint) = ::glIsTransformFeedback; -void (* const glPauseTransformFeedback)() = ::glPauseTransformFeedback; -void (* const glResumeTransformFeedback)() = ::glResumeTransformFeedback; -void (* const glGetProgramBinary)(GLuint, GLsizei, GLsizei *, GLenum *, GLvoid *) = ::glGetProgramBinary; -void (* const glProgramBinary)(GLuint, GLenum, const GLvoid *, GLsizei) = ::glProgramBinary; -void (* const glProgramParameteri)(GLuint, GLenum, GLint) = ::glProgramParameteri; +void (*const glReadBuffer)(GLenum) = ::glReadBuffer; +void (*const glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid*) = ::glDrawRangeElements; +void (*const glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*) = + ::glTexImage3D; +void (*const glTexSubImage3D)( + GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*) = ::glTexSubImage3D; +void (*const glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = + ::glCopyTexSubImage3D; +void (*const glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*) = + ::glCompressedTexImage3D; +void (*const glCompressedTexSubImage3D)( + GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*) = + ::glCompressedTexSubImage3D; +void (*const glGenQueries)(GLsizei, GLuint*) = ::glGenQueries; +void (*const glDeleteQueries)(GLsizei, const GLuint*) = ::glDeleteQueries; +GLboolean (*const glIsQuery)(GLuint) = ::glIsQuery; +void (*const glBeginQuery)(GLenum, GLuint) = ::glBeginQuery; +void (*const glEndQuery)(GLenum) = ::glEndQuery; +void (*const glGetQueryiv)(GLenum, GLenum, GLint*) = ::glGetQueryiv; +void (*const glGetQueryObjectuiv)(GLuint, GLenum, GLuint*) = ::glGetQueryObjectuiv; +GLboolean (*const glUnmapBuffer)(GLenum) = ::glUnmapBuffer; +void (*const glGetBufferPointerv)(GLenum, GLenum, GLvoid**) = ::glGetBufferPointerv; +void (*const glDrawBuffers)(GLsizei, const GLenum*) = ::glDrawBuffers; +void (*const glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix2x3fv; +void (*const glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix3x2fv; +void (*const glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix2x4fv; +void (*const glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix4x2fv; +void (*const glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix3x4fv; +void (*const glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat*) = ::glUniformMatrix4x3fv; +void (*const glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = + ::glBlitFramebuffer; +void (*const glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = + ::glRenderbufferStorageMultisample; +void (*const glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = ::glFramebufferTextureLayer; +GLvoid* (*const glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = ::glMapBufferRange; +void (*const glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = ::glFlushMappedBufferRange; +void (*const glBindVertexArray)(GLuint) = ::glBindVertexArray; +void (*const glDeleteVertexArrays)(GLsizei, const GLuint*) = ::glDeleteVertexArrays; +void (*const glGenVertexArrays)(GLsizei, GLuint*) = ::glGenVertexArrays; +GLboolean (*const glIsVertexArray)(GLuint) = ::glIsVertexArray; +void (*const glGetIntegeri_v)(GLenum, GLuint, GLint*) = ::glGetIntegeri_v; +void (*const glBeginTransformFeedback)(GLenum) = ::glBeginTransformFeedback; +void (*const glEndTransformFeedback)() = ::glEndTransformFeedback; +void (*const glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = ::glBindBufferRange; +void (*const glBindBufferBase)(GLenum, GLuint, GLuint) = ::glBindBufferBase; +void (*const glTransformFeedbackVaryings)(GLuint, + GLsizei, + const GLchar* const*, + GLenum) = ::glTransformFeedbackVaryings; +void (*const glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei*, GLsizei*, GLenum*, GLchar*) = + ::glGetTransformFeedbackVarying; +void (*const glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid*) = ::glVertexAttribIPointer; +void (*const glGetVertexAttribIiv)(GLuint, GLenum, GLint*) = ::glGetVertexAttribIiv; +void (*const glGetVertexAttribIuiv)(GLuint, GLenum, GLuint*) = ::glGetVertexAttribIuiv; +void (*const glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = ::glVertexAttribI4i; +void (*const glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = ::glVertexAttribI4ui; +void (*const glVertexAttribI4iv)(GLuint, const GLint*) = ::glVertexAttribI4iv; +void (*const glVertexAttribI4uiv)(GLuint, const GLuint*) = ::glVertexAttribI4uiv; +void (*const glGetUniformuiv)(GLuint, GLint, GLuint*) = ::glGetUniformuiv; +GLint (*const glGetFragDataLocation)(GLuint, const GLchar*) = ::glGetFragDataLocation; +void (*const glUniform1ui)(GLint, GLuint) = ::glUniform1ui; +void (*const glUniform2ui)(GLint, GLuint, GLuint) = ::glUniform2ui; +void (*const glUniform3ui)(GLint, GLuint, GLuint, GLuint) = ::glUniform3ui; +void (*const glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = ::glUniform4ui; +void (*const glUniform1uiv)(GLint, GLsizei, const GLuint*) = ::glUniform1uiv; +void (*const glUniform2uiv)(GLint, GLsizei, const GLuint*) = ::glUniform2uiv; +void (*const glUniform3uiv)(GLint, GLsizei, const GLuint*) = ::glUniform3uiv; +void (*const glUniform4uiv)(GLint, GLsizei, const GLuint*) = ::glUniform4uiv; +void (*const glClearBufferiv)(GLenum, GLint, const GLint*) = ::glClearBufferiv; +void (*const glClearBufferuiv)(GLenum, GLint, const GLuint*) = ::glClearBufferuiv; +void (*const glClearBufferfv)(GLenum, GLint, const GLfloat*) = ::glClearBufferfv; +void (*const glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = ::glClearBufferfi; +const GLubyte* (*const glGetStringi)(GLenum, GLuint) = ::glGetStringi; +void (*const glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = ::glCopyBufferSubData; +void (*const glGetUniformIndices)(GLuint, GLsizei, const GLchar* const*, GLuint*) = ::glGetUniformIndices; +void (*const glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint*, GLenum, GLint*) = ::glGetActiveUniformsiv; +GLuint (*const glGetUniformBlockIndex)(GLuint, const GLchar*) = ::glGetUniformBlockIndex; +void (*const glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint*) = ::glGetActiveUniformBlockiv; +void (*const glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei*, GLchar*) = ::glGetActiveUniformBlockName; +void (*const glUniformBlockBinding)(GLuint, GLuint, GLuint) = ::glUniformBlockBinding; +void (*const glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = ::glDrawArraysInstanced; +void (*const glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid*, GLsizei) = ::glDrawElementsInstanced; +GLsync (*const glFenceSync)(GLenum, GLbitfield) = ::glFenceSync; +GLboolean (*const glIsSync)(GLsync) = ::glIsSync; +void (*const glDeleteSync)(GLsync) = ::glDeleteSync; +GLenum (*const glClientWaitSync)(GLsync, GLbitfield, GLuint64) = ::glClientWaitSync; +void (*const glWaitSync)(GLsync, GLbitfield, GLuint64) = ::glWaitSync; +void (*const glGetInteger64v)(GLenum, GLint64*) = ::glGetInteger64v; +void (*const glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei*, GLint*) = ::glGetSynciv; +void (*const glGetInteger64i_v)(GLenum, GLuint, GLint64*) = ::glGetInteger64i_v; +void (*const glGetBufferParameteri64v)(GLenum, GLenum, GLint64*) = ::glGetBufferParameteri64v; +void (*const glGenSamplers)(GLsizei, GLuint*) = ::glGenSamplers; +void (*const glDeleteSamplers)(GLsizei, const GLuint*) = ::glDeleteSamplers; +GLboolean (*const glIsSampler)(GLuint) = ::glIsSampler; +void (*const glBindSampler)(GLuint, GLuint) = ::glBindSampler; +void (*const glSamplerParameteri)(GLuint, GLenum, GLint) = ::glSamplerParameteri; +void (*const glSamplerParameteriv)(GLuint, GLenum, const GLint*) = ::glSamplerParameteriv; +void (*const glSamplerParameterf)(GLuint, GLenum, GLfloat) = ::glSamplerParameterf; +void (*const glSamplerParameterfv)(GLuint, GLenum, const GLfloat*) = ::glSamplerParameterfv; +void (*const glGetSamplerParameteriv)(GLuint, GLenum, GLint*) = ::glGetSamplerParameteriv; +void (*const glGetSamplerParameterfv)(GLuint, GLenum, GLfloat*) = ::glGetSamplerParameterfv; +void (*const glVertexAttribDivisor)(GLuint, GLuint) = ::glVertexAttribDivisor; +void (*const glBindTransformFeedback)(GLenum, GLuint) = ::glBindTransformFeedback; +void (*const glDeleteTransformFeedbacks)(GLsizei, const GLuint*) = ::glDeleteTransformFeedbacks; +void (*const glGenTransformFeedbacks)(GLsizei, GLuint*) = ::glGenTransformFeedbacks; +GLboolean (*const glIsTransformFeedback)(GLuint) = ::glIsTransformFeedback; +void (*const glPauseTransformFeedback)() = ::glPauseTransformFeedback; +void (*const glResumeTransformFeedback)() = ::glResumeTransformFeedback; +void (*const glGetProgramBinary)(GLuint, GLsizei, GLsizei*, GLenum*, GLvoid*) = ::glGetProgramBinary; +void (*const glProgramBinary)(GLuint, GLenum, const GLvoid*, GLsizei) = ::glProgramBinary; +void (*const glProgramParameteri)(GLuint, GLenum, GLint) = ::glProgramParameteri; #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR -void (* const glInvalidateFramebuffer)(GLenum, GLsizei, const GLenum *) = ::glInvalidateFramebuffer; -void (* const glInvalidateSubFramebuffer)(GLenum, GLsizei, const GLenum *, GLint, GLint, GLsizei, GLsizei) = ::glInvalidateSubFramebuffer; +void (*const glInvalidateFramebuffer)(GLenum, GLsizei, const GLenum*) = ::glInvalidateFramebuffer; +void (*const glInvalidateSubFramebuffer)(GLenum, GLsizei, const GLenum*, GLint, GLint, GLsizei, GLsizei) = + ::glInvalidateSubFramebuffer; #endif -void (* const glTexStorage2D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = ::glTexStorage2D; -void (* const glTexStorage3D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei) = ::glTexStorage3D; -void (* const glGetInternalformativ)(GLenum, GLenum, GLenum, GLsizei, GLint *) = ::glGetInternalformativ; +void (*const glTexStorage2D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = ::glTexStorage2D; +void (*const glTexStorage3D)(GLenum, GLsizei, GLenum, GLsizei, GLsizei, GLsizei) = ::glTexStorage3D; +void (*const glGetInternalformativ)(GLenum, GLenum, GLenum, GLsizei, GLint*) = ::glGetInternalformativ; - -} // namespace platform -} // namespace mbgl +} // namespace platform +} // namespace mbgl diff --git a/platform/darwin/src/run_loop.cpp b/platform/darwin/src/run_loop.cpp index bf5bf71d0..7779b2c98 100644 --- a/platform/darwin/src/run_loop.cpp +++ b/platform/darwin/src/run_loop.cpp @@ -20,7 +20,7 @@ RunLoop* RunLoop::Get() { } RunLoop::RunLoop(Type) - : impl(std::make_unique()) { + : impl(std::make_unique()) { assert(!Scheduler::GetCurrent()); Scheduler::SetCurrent(this); impl->async = std::make_unique(std::bind(&RunLoop::process, this)); diff --git a/platform/darwin/src/timer.cpp b/platform/darwin/src/timer.cpp index e9e58d86c..6006a3719 100644 --- a/platform/darwin/src/timer.cpp +++ b/platform/darwin/src/timer.cpp @@ -18,14 +18,9 @@ public: Impl(Duration timeout, Duration repeat, std::function&& fn) : task(std::move(fn)), loop(CFRunLoopGetCurrent()) { - CFRunLoopTimerContext context = { - 0, - this, - nullptr, - nullptr, - nullptr - }; - timer = CFRunLoopTimerCreate(kCFAllocatorDefault, toCFAbsoluteTime(timeout), toCFTimeInterval(repeat), 0, 0, perform, &context); + CFRunLoopTimerContext context = {0, this, nullptr, nullptr, nullptr}; + timer = CFRunLoopTimerCreate( + kCFAllocatorDefault, toCFAbsoluteTime(timeout), toCFTimeInterval(repeat), 0, 0, perform, &context); CFRunLoopAddTimer(loop, timer, kCFRunLoopDefaultMode); } @@ -35,9 +30,7 @@ public: } private: - static void perform(CFRunLoopTimerRef, void* info) { - reinterpret_cast(info)->task(); - } + static void perform(CFRunLoopTimerRef, void* info) { reinterpret_cast(info)->task(); } std::function task; diff --git a/platform/darwin/test/MLNStyleLayerTests.h b/platform/darwin/test/MLNStyleLayerTests.h index a6e2e4ca4..5b2c19a84 100644 --- a/platform/darwin/test/MLNStyleLayerTests.h +++ b/platform/darwin/test/MLNStyleLayerTests.h @@ -1,8 +1,7 @@ #import #import -#define MLNConstantExpression(constant) \ - [NSExpression expressionForConstantValue:constant] +#define MLNConstantExpression(constant) [NSExpression expressionForConstantValue:constant] @interface MLNStyleLayerTests : XCTestCase diff --git a/platform/darwin/test/MLNTestUtility.h b/platform/darwin/test/MLNTestUtility.h index 289a3d5a2..d3030cbe4 100644 --- a/platform/darwin/test/MLNTestUtility.h +++ b/platform/darwin/test/MLNTestUtility.h @@ -15,13 +15,14 @@ will also be picked up by xcpretty. PENDING tests will be distinguished by a `⧖` and `[PENDING]` */ -#define MLN_CHECK_IF_PENDING_TEST_SHOULD_RUN() \ - /* By default, skip pending tests. Otherwise check environment for MAPBOX_RUN_PENDING_TESTS */ \ - { \ - NSString *runPendingTests = [[NSProcessInfo processInfo] environment][@"MAPBOX_RUN_PENDING_TESTS"]; \ - if (![runPendingTests boolValue]) { \ - /* The following warning will be picked up by xcpretty */ \ - printf("warning: '%s' is a pending test - skipping\n", __PRETTY_FUNCTION__); \ - return; \ - } \ - } +#define MLN_CHECK_IF_PENDING_TEST_SHOULD_RUN() \ + /* By default, skip pending tests. Otherwise check environment for MAPBOX_RUN_PENDING_TESTS */ \ + { \ + NSString *runPendingTests = \ + [[NSProcessInfo processInfo] environment][@"MAPBOX_RUN_PENDING_TESTS"]; \ + if (![runPendingTests boolValue]) { \ + /* The following warning will be picked up by xcpretty */ \ + printf("warning: '%s' is a pending test - skipping\n", __PRETTY_FUNCTION__); \ + return; \ + } \ + } diff --git a/platform/darwin/test/test-Bridging-Header.h b/platform/darwin/test/test-Bridging-Header.h index 1b2cb5d6d..e11d920b1 100644 --- a/platform/darwin/test/test-Bridging-Header.h +++ b/platform/darwin/test/test-Bridging-Header.h @@ -1,4 +1,3 @@ // // Use this file to import your target's public headers that you would like to expose to Swift. // - diff --git a/platform/ios/Integration_Test_Harness/AppDelegate.h b/platform/ios/Integration_Test_Harness/AppDelegate.h index 2a9bac67c..a5a8b3852 100644 --- a/platform/ios/Integration_Test_Harness/AppDelegate.h +++ b/platform/ios/Integration_Test_Harness/AppDelegate.h @@ -5,4 +5,3 @@ @property (strong, nonatomic) UIWindow *window; @end - diff --git a/platform/ios/Integration_Tests/MLNIntegrationTestCase.h b/platform/ios/Integration_Tests/MLNIntegrationTestCase.h index 0e90ceb53..5fc4562d9 100644 --- a/platform/ios/Integration_Tests/MLNIntegrationTestCase.h +++ b/platform/ios/Integration_Tests/MLNIntegrationTestCase.h @@ -1,28 +1,29 @@ -#import #import +#import #import "MLNTestUtility.h" -#define MLNTestFail(myself, ...) \ -_XCTPrimitiveFail(myself, __VA_ARGS__) +#define MLNTestFail(myself, ...) _XCTPrimitiveFail(myself, __VA_ARGS__) #define MLNTestAssert(myself, expression, ...) \ - _XCTPrimitiveAssertTrue(myself, expression, @#expression, __VA_ARGS__) + _XCTPrimitiveAssertTrue(myself, expression, @ #expression, __VA_ARGS__) -#define MLNTestAssertEqualWithAccuracy(myself, expression1, expression2, accuracy, ...) \ - _XCTPrimitiveAssertEqualWithAccuracy(myself, expression1, @#expression1, expression2, @#expression2, accuracy, @#accuracy, __VA_ARGS__) +#define MLNTestAssertEqualWithAccuracy(myself, expression1, expression2, accuracy, ...) \ + _XCTPrimitiveAssertEqualWithAccuracy(myself, expression1, @ #expression1, expression2, \ + @ #expression2, accuracy, @ #accuracy, __VA_ARGS__) #define MLNTestAssertNil(myself, expression, ...) \ - _XCTPrimitiveAssertNil(myself, expression, @#expression, __VA_ARGS__) + _XCTPrimitiveAssertNil(myself, expression, @ #expression, __VA_ARGS__) #define MLNTestAssertNotNil(myself, expression, ...) \ - _XCTPrimitiveAssertNotNil(myself, expression, @#expression, __VA_ARGS__) + _XCTPrimitiveAssertNotNil(myself, expression, @ #expression, __VA_ARGS__) -#define MLNTestWarning(expression, format, ...) \ - ({ \ - if (!(expression)) { \ - NSString *message = [NSString stringWithFormat:format, ##__VA_ARGS__]; \ - printf("warning: Test Case '%s' at line %d: '%s' %s\n", __PRETTY_FUNCTION__, __LINE__, #expression, message.UTF8String); \ - } \ - }) +#define MLNTestWarning(expression, format, ...) \ + ({ \ + if (!(expression)) { \ + NSString *message = [NSString stringWithFormat:format, ##__VA_ARGS__]; \ + printf("warning: Test Case '%s' at line %d: '%s' %s\n", __PRETTY_FUNCTION__, __LINE__, \ + #expression, message.UTF8String); \ + } \ + }) -@interface MLNIntegrationTestCase: XCTestCase +@interface MLNIntegrationTestCase : XCTestCase @end diff --git a/platform/ios/Integration_Tests/MLNMapViewIntegrationTest.h b/platform/ios/Integration_Tests/MLNMapViewIntegrationTest.h index 574ed03b9..a4dfe97a8 100644 --- a/platform/ios/Integration_Tests/MLNMapViewIntegrationTest.h +++ b/platform/ios/Integration_Tests/MLNMapViewIntegrationTest.h @@ -6,13 +6,17 @@ @property (nonatomic) MLNStyle *style; @property (nonatomic) XCTestExpectation *styleLoadingExpectation; @property (nonatomic) XCTestExpectation *renderFinishedExpectation; -@property (nonatomic) MLNAnnotationView * (^viewForAnnotation)(MLNMapView *mapView, id annotation); +@property (nonatomic) MLNAnnotationView * (^viewForAnnotation) + (MLNMapView *mapView, id annotation); @property (nonatomic) void (^regionWillChange)(MLNMapView *mapView, BOOL animated); @property (nonatomic) void (^regionIsChanging)(MLNMapView *mapView); -@property (nonatomic) void (^regionDidChange)(MLNMapView *mapView, MLNCameraChangeReason reason, BOOL animated); +@property (nonatomic) void (^regionDidChange) + (MLNMapView *mapView, MLNCameraChangeReason reason, BOOL animated); @property (nonatomic) CGPoint (^mapViewUserLocationAnchorPoint)(MLNMapView *mapView); -@property (nonatomic) BOOL (^mapViewAnnotationCanShowCalloutForAnnotation)(MLNMapView *mapView, id annotation); -@property (nonatomic) id (^mapViewCalloutViewForAnnotation)(MLNMapView *mapView, id annotation); +@property (nonatomic) BOOL (^mapViewAnnotationCanShowCalloutForAnnotation) + (MLNMapView *mapView, id annotation); +@property (nonatomic) id (^mapViewCalloutViewForAnnotation) + (MLNMapView *mapView, id annotation); // Utility methods - (void)waitForMapViewToFinishLoadingStyleWithTimeout:(NSTimeInterval)timeout; diff --git a/platform/ios/Integration_Tests/MLNTestLocationManager.h b/platform/ios/Integration_Tests/MLNTestLocationManager.h index 72fc80fd2..810c6e6d5 100644 --- a/platform/ios/Integration_Tests/MLNTestLocationManager.h +++ b/platform/ios/Integration_Tests/MLNTestLocationManager.h @@ -1,10 +1,10 @@ -#import #import +#import #import "MLNTestUtility.h" -@interface MLNTestLocationManager : NSObject +@interface MLNTestLocationManager : NSObject @end -@interface MLNTestLocationManager() +@interface MLNTestLocationManager () @end diff --git a/platform/ios/Integration_Tests/integration-Bridging-Header.h b/platform/ios/Integration_Tests/integration-Bridging-Header.h index 7ac0b2480..2074cef8f 100644 --- a/platform/ios/Integration_Tests/integration-Bridging-Header.h +++ b/platform/ios/Integration_Tests/integration-Bridging-Header.h @@ -2,4 +2,3 @@ // Use this file to import your target's public headers that you would like to expose to Swift. // #import "MLNMapViewIntegrationTest.h" - diff --git a/platform/ios/app/MBXStateManager.h b/platform/ios/app/MBXStateManager.h index 1a3c8810e..3e5f8e33b 100644 --- a/platform/ios/app/MBXStateManager.h +++ b/platform/ios/app/MBXStateManager.h @@ -6,11 +6,11 @@ NS_ASSUME_NONNULL_BEGIN @interface MBXStateManager : NSObject -+ (instancetype) sharedManager; ++ (instancetype)sharedManager; - (MBXState *)currentState; -- (void)saveState:(MBXState*)mapViewController; +- (void)saveState:(MBXState *)mapViewController; - (void)resetState; diff --git a/platform/ios/benchmark/MBXBenchViewController.h b/platform/ios/benchmark/MBXBenchViewController.h index c93e28d6a..5ee00e6ee 100644 --- a/platform/ios/benchmark/MBXBenchViewController.h +++ b/platform/ios/benchmark/MBXBenchViewController.h @@ -1,5 +1,5 @@ -#import #import +#import @interface MBXBenchViewController : UIViewController diff --git a/platform/ios/benchmark/locations.cpp b/platform/ios/benchmark/locations.cpp index e2ff09ffc..718a1adef 100644 --- a/platform/ios/benchmark/locations.cpp +++ b/platform/ios/benchmark/locations.cpp @@ -4,23 +4,23 @@ namespace mbgl { namespace bench { const std::vector locations = { - { "SF zoom in", -122.4194, 37.7749, 14, 0.0 }, - { "SF zoom out", -122.4194, 37.7749, 2, 0.0 }, - { "DC zoom in", -77.0369, 38.9072, 14, 0.0 }, - { "DC zoom out", -77.0369, 38.9072, 2, 0.0 }, - { "AMS zoom in", 4.8952, 52.3702, 14, 0.0 }, - { "AMS zoom out", 4.8952, 52.3702, 2, 0.0 }, - { "HEL zoom in", 24.9384, 60.1699, 14, 0.0 }, - { "HEL zoom out", 24.9384, 60.1699, 2, 0.0 }, - { "AYA zoom in", -74.2236, -13.1639, 14, 0.0 }, - { "AYA zoom out", -74.2236, -13.1639, 2, 0.0 }, - { "BER zoom in", 13.4050, 52.5200, 14, 0.0 }, - { "BER zoom out", 13.4050, 52.5200, 2, 0.0 }, - { "BAN zoom in", 77.5946, 12.9716, 14, 0.0 }, - { "BAN zoom out", 77.5946, 12.9716, 2, 0.0 }, - { "SHA zoom in", 121.4737, 31.2304, 14, 0.0 }, - { "SHA zoom out", 121.4737, 31.2304, 2, 0.0 }, + {"SF zoom in", -122.4194, 37.7749, 14, 0.0}, + {"SF zoom out", -122.4194, 37.7749, 2, 0.0}, + {"DC zoom in", -77.0369, 38.9072, 14, 0.0}, + {"DC zoom out", -77.0369, 38.9072, 2, 0.0}, + {"AMS zoom in", 4.8952, 52.3702, 14, 0.0}, + {"AMS zoom out", 4.8952, 52.3702, 2, 0.0}, + {"HEL zoom in", 24.9384, 60.1699, 14, 0.0}, + {"HEL zoom out", 24.9384, 60.1699, 2, 0.0}, + {"AYA zoom in", -74.2236, -13.1639, 14, 0.0}, + {"AYA zoom out", -74.2236, -13.1639, 2, 0.0}, + {"BER zoom in", 13.4050, 52.5200, 14, 0.0}, + {"BER zoom out", 13.4050, 52.5200, 2, 0.0}, + {"BAN zoom in", 77.5946, 12.9716, 14, 0.0}, + {"BAN zoom out", 77.5946, 12.9716, 2, 0.0}, + {"SHA zoom in", 121.4737, 31.2304, 14, 0.0}, + {"SHA zoom out", 121.4737, 31.2304, 2, 0.0}, }; } -} +} // namespace mbgl diff --git a/platform/ios/benchmark/locations.hpp b/platform/ios/benchmark/locations.hpp index 1ea65d628..91cfa11d0 100644 --- a/platform/ios/benchmark/locations.hpp +++ b/platform/ios/benchmark/locations.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include namespace mbgl { namespace bench { @@ -16,5 +16,5 @@ struct Location { extern const std::vector locations; -} -} +} // namespace bench +} // namespace mbgl diff --git a/platform/ios/src/MLNAnnotationContainerView.h b/platform/ios/src/MLNAnnotationContainerView.h index 33b9737a3..de8105cd5 100644 --- a/platform/ios/src/MLNAnnotationContainerView.h +++ b/platform/ios/src/MLNAnnotationContainerView.h @@ -8,7 +8,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MLNAnnotationContainerView : UIView -+ (instancetype)annotationContainerViewWithAnnotationContainerView:(MLNAnnotationContainerView *)annotationContainerView; ++ (instancetype)annotationContainerViewWithAnnotationContainerView: + (MLNAnnotationContainerView *)annotationContainerView; - (void)addSubviews:(NSArray *)subviews; diff --git a/platform/ios/src/MLNAnnotationImage.h b/platform/ios/src/MLNAnnotationImage.h index 2d2a49263..6894c7400 100644 --- a/platform/ios/src/MLNAnnotationImage.h +++ b/platform/ios/src/MLNAnnotationImage.h @@ -9,10 +9,10 @@ NS_ASSUME_NONNULL_BEGIN annotations visually on a map view. Annotation image objects wrap `UIImage` objects and may be recycled later and put into a reuse queue that is maintained by the map view. - + #### Related examples TODO: Mark a place on the map with an image, learn how use an image - as a marker using `MLNAnnotationImage`. + as a marker using `MLNAnnotationImage`. */ MLN_EXPORT @interface MLNAnnotationImage : NSObject @@ -28,7 +28,8 @@ MLN_EXPORT @return The initialized annotation image object or `nil` if there was a problem initializing the object. */ -+ (instancetype)annotationImageWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier; ++ (instancetype)annotationImageWithImage:(UIImage *)image + reuseIdentifier:(NSString *)reuseIdentifier; // MARK: Getting and Setting Attributes diff --git a/platform/ios/src/MLNAnnotationView.h b/platform/ios/src/MLNAnnotationView.h index 07081fdf0..6e139d030 100644 --- a/platform/ios/src/MLNAnnotationView.h +++ b/platform/ios/src/MLNAnnotationView.h @@ -8,34 +8,34 @@ NS_ASSUME_NONNULL_BEGIN /** These constants indicate the current drag state of an annotation view. */ typedef NS_ENUM(NSUInteger, MLNAnnotationViewDragState) { - /** - The view is not involved in a drag operation. - */ - MLNAnnotationViewDragStateNone = 0, - /** - An action occurred that indicated the view should begin dragging. + /** + The view is not involved in a drag operation. + */ + MLNAnnotationViewDragStateNone = 0, + /** + An action occurred that indicated the view should begin dragging. - The map view automatically moves draggable annotation views to this state - in response to the dragging the view after pressing and holding on it. - */ - MLNAnnotationViewDragStateStarting, - /** - The view is in the midst of a drag operation and is actively tracking the - user’s gesture. - */ - MLNAnnotationViewDragStateDragging, - /** - An action occurred that indicated the view should cancel the drag - operation. - */ - MLNAnnotationViewDragStateCanceling, - /** - An action occurred that indicated the view was dropped by the user. + The map view automatically moves draggable annotation views to this state + in response to the dragging the view after pressing and holding on it. + */ + MLNAnnotationViewDragStateStarting, + /** + The view is in the midst of a drag operation and is actively tracking the + user’s gesture. + */ + MLNAnnotationViewDragStateDragging, + /** + An action occurred that indicated the view should cancel the drag + operation. + */ + MLNAnnotationViewDragStateCanceling, + /** + An action occurred that indicated the view was dropped by the user. - The map view automatically moves annotation views to this state in response - to the user lifting their finger at the end of a drag gesture. - */ - MLNAnnotationViewDragStateEnding, + The map view automatically moves annotation views to this state in response + to the user lifting their finger at the end of a drag gesture. + */ + MLNAnnotationViewDragStateEnding, }; /** @@ -78,7 +78,7 @@ MLN_EXPORT /** Initializes and returns a new annotation view object. - + Providing an annotation allows you to explicitly associate the annotation instance with the new view and, in custom subclasses of `MLNAnnotationView`, customize the view based on properties of the annotation instance in an overridden initializer. However, @@ -86,16 +86,16 @@ MLN_EXPORT same annotation they were initialized with. Also, annotation views that are in the reuse queue will have a nil value for the annotation property. Passing an annotation instance to the view is optional and the map view will automatically associate annotations - with views when views are provided to the map via the `-[MLNMapViewDelegate mapView:viewForAnnotation:]` - method. - + with views when views are provided to the map via the `-[MLNMapViewDelegate + mapView:viewForAnnotation:]` method. + The reuse identifier provides a way for you to improve performance by recycling annotation views as they enter and leave the map’s viewport. As an annotation leaves the viewport, the map view moves its associated view to a reuse queue. When a new annotation becomes visible, you can request a view for that annotation by passing the appropriate reuse identifier string to the `-[MLNMapView dequeueReusableAnnotationViewWithIdentifier:]` method. - + @param annotation The annotation object to associate with the new view. @param reuseIdentifier A unique string identifier for this view that allows you to reuse this view with multiple similar annotations. You can set this @@ -104,7 +104,8 @@ MLN_EXPORT views. @return The initialized annotation view object. */ -- (instancetype)initWithAnnotation:(nullable id)annotation reuseIdentifier:(nullable NSString *)reuseIdentifier; +- (instancetype)initWithAnnotation:(nullable id)annotation + reuseIdentifier:(nullable NSString *)reuseIdentifier; /** Called when the view is removed from the reuse queue. @@ -122,7 +123,7 @@ MLN_EXPORT contains a non-`nil` value while the annotation view is visible on the map. If the view is queued, waiting to be reused, the value is `nil`. */ -@property (nonatomic, nullable) id annotation; +@property (nonatomic, nullable) id annotation; /** The string that identifies that this annotation view is reusable. @@ -222,7 +223,7 @@ MLN_EXPORT if it should display itself as unselected. @param animated `YES` if the change in selection state is animated; `NO` if the change is immediate. - + #### Related examples TODO: modify an `MLNAnnotationView`'s behavior when it is selected. */ @@ -253,7 +254,7 @@ MLN_EXPORT attempting to stop an operation that has already been initiated; doing so can lead to undefined behavior. Once begun, the drag operation should always continue to completion. - + #### Related examples TODO: Enable users to drag `MLNAnnotationView` objects on your map. */ @@ -275,7 +276,8 @@ MLN_EXPORT drags it. As the system detects user actions that would indicate a drag, it calls this method to update the drag state. */ -- (void)setDragState:(MLNAnnotationViewDragState)dragState animated:(BOOL)animated NS_REQUIRES_SUPER; +- (void)setDragState:(MLNAnnotationViewDragState)dragState + animated:(BOOL)animated NS_REQUIRES_SUPER; @end diff --git a/platform/ios/src/MLNAnnotationView_Private.h b/platform/ios/src/MLNAnnotationView_Private.h index 312856dc8..000b1b7ce 100644 --- a/platform/ios/src/MLNAnnotationView_Private.h +++ b/platform/ios/src/MLNAnnotationView_Private.h @@ -1,5 +1,5 @@ -#import "MLNAnnotationView.h" #import "MLNAnnotation.h" +#import "MLNAnnotationView.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/ios/src/MLNCalloutView.h b/platform/ios/src/MLNCalloutView.h index 86b9f59f0..f36b3cb7f 100644 --- a/platform/ios/src/MLNCalloutView.h +++ b/platform/ios/src/MLNCalloutView.h @@ -9,10 +9,10 @@ NS_ASSUME_NONNULL_BEGIN /** A protocol for a `UIView` subclass that displays information about a selected annotation near that annotation. - + To receive updates from an object that conforms to the `MLNCalloutView` protocol, use the optional methods available in the `MLNCalloutViewDelegate` protocol. - + #### Related examples TODO: Display custom views as callouts by customizing an `MLNCalloutView`. @@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN An object conforming to the `MLNAnnotation` protocol whose details this callout view displays. */ -@property (nonatomic, strong) id representedObject; +@property (nonatomic, strong) id representedObject; /** A view that the user may tap to perform an action. This view is conventionally @@ -47,14 +47,21 @@ NS_ASSUME_NONNULL_BEGIN Presents a callout view by adding it to `view` and pointing at the given rect of `view`’s bounds. Constrains the callout to the bounds of the given view. */ -- (void)presentCalloutFromRect:(CGRect)rect inView:(UIView *)view constrainedToView:(UIView *)constrainedView animated:(BOOL)animated __attribute__((unavailable("Use `-presentCalloutFromRect:inView:constrainedToRect:animated:` instead."))); - +- (void)presentCalloutFromRect:(CGRect)rect + inView:(UIView *)view + constrainedToView:(UIView *)constrainedView + animated:(BOOL)animated + __attribute__(( + unavailable("Use `-presentCalloutFromRect:inView:constrainedToRect:animated:` instead."))); /** Presents a callout view by adding it to `view` and pointing at the given rect of `view`’s bounds. Constrains the callout to the rect in the space of `view`. */ -- (void)presentCalloutFromRect:(CGRect)rect inView:(UIView *)view constrainedToRect:(CGRect)constrainedRect animated:(BOOL)animated; +- (void)presentCalloutFromRect:(CGRect)rect + inView:(UIView *)view + constrainedToRect:(CGRect)constrainedRect + animated:(BOOL)animated; /** Dismisses the callout view. @@ -67,19 +74,20 @@ NS_ASSUME_NONNULL_BEGIN If implemented, should provide margins to expand the rect the callout is presented from. These are used to determine positioning. Currently only the top and bottom properties of the return - value are used. For example, `{ .top = -50.0, .left = -10.0, .bottom = 0.0, .right = -10.0 }` indicates - a 50 point margin above the presentation origin rect (and 10 point margins to the left and the right) - in which the callout is assumed to be displayed. + value are used. For example, `{ .top = -50.0, .left = -10.0, .bottom = 0.0, .right = -10.0 }` + indicates a 50 point margin above the presentation origin rect (and 10 point margins to the left + and the right) in which the callout is assumed to be displayed. There are no assumed defaults for these margins, as they should be calculated from the callout that - is to be presented. For example, `SMCalloutView` generates the top margin from the callout height, but - the left and right margins from a minimum width that the callout should have. + is to be presented. For example, `SMCalloutView` generates the top margin from the callout height, + but the left and right margins from a minimum width that the callout should have. @param rect Rect that the callout is presented from. This should be the same as the one passed in `-[MLNCalloutView presentCalloutFromRect:inView:constrainedToRect:animated:]` @return `UIEdgeInsets` representing the margins. Values should be negative. */ -- (UIEdgeInsets)marginInsetsHintForPresentationFromRect:(CGRect)rect NS_SWIFT_NAME(marginInsetsHintForPresentation(from:)); +- (UIEdgeInsets)marginInsetsHintForPresentationFromRect:(CGRect)rect + NS_SWIFT_NAME(marginInsetsHintForPresentation(from:)); /** A Boolean value indicating whether the callout view should be anchored to diff --git a/platform/ios/src/MLNCameraChangeReason.h b/platform/ios/src/MLNCameraChangeReason.h index 1e8b9e899..f0822482a 100644 --- a/platform/ios/src/MLNCameraChangeReason.h +++ b/platform/ios/src/MLNCameraChangeReason.h @@ -12,7 +12,8 @@ - `-mapView:regionDidChangeWithReason:animated:` It's important to note that it's almost impossible to perform a rotate without zooming (in or out), - so if you'll often find `MLNCameraChangeReasonGesturePinch` set alongside `MLNCameraChangeReasonGestureRotate`. + so if you'll often find `MLNCameraChangeReasonGesturePinch` set alongside + `MLNCameraChangeReasonGestureRotate`. Since there are several reasons why a zoom or rotation has occurred, it is worth considering creating a combined constant, for example: @@ -23,43 +24,44 @@ MLNCameraChangeReasonGestureZoomOut | MLNCameraChangeReasonGestureOneFingerZoom; - static const MLNCameraChangeReason anyRotation = MLNCameraChangeReasonResetNorth | MLNCameraChangeReasonGestureRotate; + static const MLNCameraChangeReason anyRotation = MLNCameraChangeReasonResetNorth | + MLNCameraChangeReasonGestureRotate; ``` */ -typedef NS_OPTIONS(NSUInteger, MLNCameraChangeReason) -{ - /// :nodoc: The reason for the camera change has not be specified. - MLNCameraChangeReasonNone = 0, +typedef NS_OPTIONS(NSUInteger, MLNCameraChangeReason) { + /// :nodoc: The reason for the camera change has not be specified. + MLNCameraChangeReasonNone = 0, - /// :nodoc: Set when a public API that moves the camera is called. This may be set for some gestures, - /// for example MLNCameraChangeReasonResetNorth. - MLNCameraChangeReasonProgrammatic = 1 << 0, + /// :nodoc: Set when a public API that moves the camera is called. This may be set for some + /// gestures, for example MLNCameraChangeReasonResetNorth. + MLNCameraChangeReasonProgrammatic = 1 << 0, - /// :nodoc: The user tapped the compass to reset the map orientation so North is up. - MLNCameraChangeReasonResetNorth = 1 << 1, + /// :nodoc: The user tapped the compass to reset the map orientation so North is up. + MLNCameraChangeReasonResetNorth = 1 << 1, - /// :nodoc: The user panned the map. - MLNCameraChangeReasonGesturePan = 1 << 2, + /// :nodoc: The user panned the map. + MLNCameraChangeReasonGesturePan = 1 << 2, - /// :nodoc: The user pinched to zoom in/out. - MLNCameraChangeReasonGesturePinch = 1 << 3, + /// :nodoc: The user pinched to zoom in/out. + MLNCameraChangeReasonGesturePinch = 1 << 3, - // :nodoc: The user rotated the map. - MLNCameraChangeReasonGestureRotate = 1 << 4, + // :nodoc: The user rotated the map. + MLNCameraChangeReasonGestureRotate = 1 << 4, - /// :nodoc: The user zoomed the map in (one finger double tap). - MLNCameraChangeReasonGestureZoomIn = 1 << 5, + /// :nodoc: The user zoomed the map in (one finger double tap). + MLNCameraChangeReasonGestureZoomIn = 1 << 5, - /// :nodoc: The user zoomed the map out (two finger single tap). - MLNCameraChangeReasonGestureZoomOut = 1 << 6, + /// :nodoc: The user zoomed the map out (two finger single tap). + MLNCameraChangeReasonGestureZoomOut = 1 << 6, - /// :nodoc: The user long pressed on the map for a quick zoom (single tap, then long press and drag up/down). - MLNCameraChangeReasonGestureOneFingerZoom = 1 << 7, + /// :nodoc: The user long pressed on the map for a quick zoom (single tap, then long press and + /// drag up/down). + MLNCameraChangeReasonGestureOneFingerZoom = 1 << 7, - // :nodoc: The user panned with two fingers to tilt the map (two finger drag). - MLNCameraChangeReasonGestureTilt = 1 << 8, + // :nodoc: The user panned with two fingers to tilt the map (two finger drag). + MLNCameraChangeReasonGestureTilt = 1 << 8, - // :nodoc: Cancelled - MLNCameraChangeReasonTransitionCancelled = 1 << 16 + // :nodoc: Cancelled + MLNCameraChangeReasonTransitionCancelled = 1 << 16 }; diff --git a/platform/ios/src/MLNCompactCalloutView.h b/platform/ios/src/MLNCompactCalloutView.h index a4591d48d..cece81c4b 100644 --- a/platform/ios/src/MLNCompactCalloutView.h +++ b/platform/ios/src/MLNCompactCalloutView.h @@ -1,5 +1,5 @@ -#import "SMCalloutView.h" #import "MLNCalloutView.h" +#import "SMCalloutView.h" /** A concrete implementation of `MLNCalloutView` based on diff --git a/platform/ios/src/MLNCompassButton.h b/platform/ios/src/MLNCompassButton.h index 5aa139368..6042664bf 100644 --- a/platform/ios/src/MLNCompassButton.h +++ b/platform/ios/src/MLNCompassButton.h @@ -13,7 +13,8 @@ MLN_EXPORT /** The visibility of the compass button. - You can configure a compass button to be visible all the time or only when the compass heading changes. + You can configure a compass button to be visible all the time or only when the compass heading + changes. */ @property (nonatomic, assign) MLNOrnamentVisibility compassVisibility; diff --git a/platform/ios/src/MLNMapAccessibilityElement.h b/platform/ios/src/MLNMapAccessibilityElement.h index cd5341675..a485cddcd 100644 --- a/platform/ios/src/MLNMapAccessibilityElement.h +++ b/platform/ios/src/MLNMapAccessibilityElement.h @@ -21,7 +21,9 @@ MLN_EXPORT /** The tag of the annotation represented by this element. */ @property (nonatomic) MLNAnnotationTag tag; -- (instancetype)initWithAccessibilityContainer:(id)container tag:(MLNAnnotationTag)identifier NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithAccessibilityContainer:(id)container + tag:(MLNAnnotationTag)identifier + NS_DESIGNATED_INITIALIZER; @end @@ -30,9 +32,10 @@ MLN_EXPORT @interface MLNFeatureAccessibilityElement : MLNMapAccessibilityElement /** The feature represented by this element. */ -@property (nonatomic, strong) id feature; +@property (nonatomic, strong) id feature; -- (instancetype)initWithAccessibilityContainer:(id)container feature:(id )feature NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithAccessibilityContainer:(id)container + feature:(id)feature NS_DESIGNATED_INITIALIZER; @end diff --git a/platform/ios/src/MLNMapProjection.h b/platform/ios/src/MLNMapProjection.h index 72b948509..f1638a29f 100644 --- a/platform/ios/src/MLNMapProjection.h +++ b/platform/ios/src/MLNMapProjection.h @@ -18,7 +18,7 @@ MLN_EXPORT @param mapView The map view the camera state to use for the initialization. @return An initialized map projection. */ -- (instancetype)initWithMapView:(MLNMapView*)mapView; +- (instancetype)initWithMapView:(MLNMapView *)mapView; /** A camera representing the current projection state @@ -32,9 +32,9 @@ MLN_EXPORT @param insets The insets applied on top of the camera be used in the projection calculation. @note `MLNMapView` instance frame must not be changed since this projection is initialized, - otherwise the calculation may be wrong. + otherwise the calculation may be wrong. */ -- (void)setCamera:(MLNMapCamera * _Nonnull)camera withEdgeInsets:(UIEdgeInsets)insets; +- (void)setCamera:(MLNMapCamera *_Nonnull)camera withEdgeInsets:(UIEdgeInsets)insets; /** Change the projection state to make the provided bounds visible with the specified inset. diff --git a/platform/ios/src/MLNMapView+IBAdditions.h b/platform/ios/src/MLNMapView+IBAdditions.h index f726c3efc..5459c61cf 100644 --- a/platform/ios/src/MLNMapView+IBAdditions.h +++ b/platform/ios/src/MLNMapView+IBAdditions.h @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN // strips out the two underscores for display. @property (nonatomic, nullable) IBInspectable NSString *styleURL__; -#endif // TARGET_INTERFACE_BUILDER +#endif // TARGET_INTERFACE_BUILDER // Convenience properties related to the initial viewport. These properties // are not meant to be used outside of Interface Builder. latitude and longitude diff --git a/platform/ios/src/MLNMapView+Impl.h b/platform/ios/src/MLNMapView+Impl.h index 04a991977..c78fd4531 100644 --- a/platform/ios/src/MLNMapView+Impl.h +++ b/platform/ios/src/MLNMapView+Impl.h @@ -4,78 +4,76 @@ #import "MLNBackendResource.h" -#import -#import #import +#import +#import @class MLNMapView; class MLNMapViewImpl : public mbgl::MapObserver { -public: - static std::unique_ptr Create(MLNMapView*); + public: + static std::unique_ptr Create(MLNMapView*); - MLNMapViewImpl(MLNMapView*); - virtual ~MLNMapViewImpl() = default; + MLNMapViewImpl(MLNMapView*); + virtual ~MLNMapViewImpl() = default; - virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0; + virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0; - // Returns a handle to the OpenGL context object if this view is rendered with OpenGL. - virtual EAGLContext* getEAGLContext() { - return nullptr; - } + // Returns a handle to the OpenGL context object if this view is rendered with OpenGL. + virtual EAGLContext* getEAGLContext() { return nullptr; } - // Gets called when the opaqueness of the view changes. - virtual void setOpaque(bool) = 0; + // Gets called when the opaqueness of the view changes. + virtual void setOpaque(bool) = 0; - // Triggers an immediate render of the underlying view. - virtual void display() = 0; + // Triggers an immediate render of the underlying view. + virtual void display() = 0; - // We update the transaction mode when the user adds annotation views that need to be layered on - // top of the view. - virtual void setPresentsWithTransaction(bool) = 0; + // We update the transaction mode when the user adds annotation views that need to be layered on + // top of the view. + virtual void setPresentsWithTransaction(bool) = 0; - // Called when initially creating the rendering view, and when resuming rendering after returning - // from the background. - virtual void createView() = 0; + // Called when initially creating the rendering view, and when resuming rendering after returning + // from the background. + virtual void createView() = 0; - // We expose the underlying UIView because we need it in order to add annotation views above it. - virtual UIView* getView() = 0; + // We expose the underlying UIView because we need it in order to add annotation views above it. + virtual UIView* getView() = 0; - // Called when the application goes to the background and we've replaced the interactively - // rendered map view with a static image. - virtual void deleteView() = 0; + // Called when the application goes to the background and we've replaced the interactively + // rendered map view with a static image. + virtual void deleteView() = 0; - // called before the application goes to the background. The resulting image is used as a place - // holder instead of the regular view. This allows us to drop the framebuffers associated with - // the rendering context and reduce memory while in the background. - virtual UIImage* snapshot() = 0; + // called before the application goes to the background. The resulting image is used as a place + // holder instead of the regular view. This allows us to drop the framebuffers associated with + // the rendering context and reduce memory while in the background. + virtual UIImage* snapshot() = 0; - // Called when UIView's layout has changed. - virtual void layoutChanged() {}; + // Called when UIView's layout has changed. + virtual void layoutChanged() {}; - // Called by the view delegate when it's time to render. - void render(); + // Called by the view delegate when it's time to render. + void render(); - virtual MLNBackendResource getObject() = 0; + virtual MLNBackendResource getObject() = 0; - // mbgl::MapObserver implementation - void onCameraWillChange(mbgl::MapObserver::CameraChangeMode) override; - void onCameraIsChanging() override; - void onCameraDidChange(mbgl::MapObserver::CameraChangeMode) override; - void onWillStartLoadingMap() override; - void onDidFinishLoadingMap() override; - void onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) override; - void onWillStartRenderingFrame() override; - void onDidFinishRenderingFrame(mbgl::MapObserver::RenderFrameStatus) override; - void onWillStartRenderingMap() override; - void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode) override; - void onDidFinishLoadingStyle() override; - void onSourceChanged(mbgl::style::Source& source) override; - void onDidBecomeIdle() override; - void onStyleImageMissing(const std::string& imageIdentifier) override; - bool onCanRemoveUnusedStyleImage(const std::string& imageIdentifier) override; + // mbgl::MapObserver implementation + void onCameraWillChange(mbgl::MapObserver::CameraChangeMode) override; + void onCameraIsChanging() override; + void onCameraDidChange(mbgl::MapObserver::CameraChangeMode) override; + void onWillStartLoadingMap() override; + void onDidFinishLoadingMap() override; + void onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) override; + void onWillStartRenderingFrame() override; + void onDidFinishRenderingFrame(mbgl::MapObserver::RenderFrameStatus) override; + void onWillStartRenderingMap() override; + void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode) override; + void onDidFinishLoadingStyle() override; + void onSourceChanged(mbgl::style::Source& source) override; + void onDidBecomeIdle() override; + void onStyleImageMissing(const std::string& imageIdentifier) override; + bool onCanRemoveUnusedStyleImage(const std::string& imageIdentifier) override; -protected: - /// Cocoa map view that this adapter bridges to. - __weak MLNMapView *mapView = nullptr; + protected: + /// Cocoa map view that this adapter bridges to. + __weak MLNMapView* mapView = nullptr; }; diff --git a/platform/ios/src/MLNMapView+Metal.h b/platform/ios/src/MLNMapView+Metal.h index f83d66413..cd7e80a15 100644 --- a/platform/ios/src/MLNMapView+Metal.h +++ b/platform/ios/src/MLNMapView+Metal.h @@ -8,45 +8,41 @@ /// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa. class MLNMapViewMetalImpl final : public MLNMapViewImpl, - public mbgl::mtl::RendererBackend, - public mbgl::gfx::Renderable { -public: - MLNMapViewMetalImpl(MLNMapView*); - ~MLNMapViewMetalImpl() override; + public mbgl::mtl::RendererBackend, + public mbgl::gfx::Renderable { + public: + MLNMapViewMetalImpl(MLNMapView*); + ~MLNMapViewMetalImpl() override; -public: - void restoreFramebufferBinding(); + public: + void restoreFramebufferBinding(); - // Implementation of mbgl::gfx::RendererBackend -public: - mbgl::gfx::Renderable& getDefaultRenderable() override { - return *this; - } + // Implementation of mbgl::gfx::RendererBackend + public: + mbgl::gfx::Renderable& getDefaultRenderable() override { return *this; } -private: - void activate() override; - void deactivate() override; - // End implementation of mbgl::gfx::RendererBackend + private: + void activate() override; + void deactivate() override; + // End implementation of mbgl::gfx::RendererBackend - // Implementation of mbgl::gl::RendererBackend -public: - void updateAssumedState() override; - // End implementation of mbgl::gl::Rendererbackend + // Implementation of mbgl::gl::RendererBackend + public: + void updateAssumedState() override; + // End implementation of mbgl::gl::Rendererbackend - // Implementation of MLNMapViewImpl -public: - mbgl::gfx::RendererBackend& getRendererBackend() override { - return *this; - } + // Implementation of MLNMapViewImpl + public: + mbgl::gfx::RendererBackend& getRendererBackend() override { return *this; } - void setOpaque(bool) override; - void display() override; - void setPresentsWithTransaction(bool) override; - void createView() override; - UIView* getView() override; - void deleteView() override; - UIImage* snapshot() override; - void layoutChanged() override; - MLNBackendResource getObject() override; - // End implementation of MLNMapViewImpl + void setOpaque(bool) override; + void display() override; + void setPresentsWithTransaction(bool) override; + void createView() override; + UIView* getView() override; + void deleteView() override; + UIImage* snapshot() override; + void layoutChanged() override; + MLNBackendResource getObject() override; + // End implementation of MLNMapViewImpl }; diff --git a/platform/ios/src/MLNMapView+OpenGL.h b/platform/ios/src/MLNMapView+OpenGL.h index 3e455f87d..bd7d60f0e 100644 --- a/platform/ios/src/MLNMapView+OpenGL.h +++ b/platform/ios/src/MLNMapView+OpenGL.h @@ -10,52 +10,48 @@ class MLNMapViewOpenGLImpl final : public MLNMapViewImpl, public mbgl::gl::RendererBackend, public mbgl::gfx::Renderable { -public: - MLNMapViewOpenGLImpl(MLNMapView*); - ~MLNMapViewOpenGLImpl() override; + public: + MLNMapViewOpenGLImpl(MLNMapView*); + ~MLNMapViewOpenGLImpl() override; -public: - void restoreFramebufferBinding(); + public: + void restoreFramebufferBinding(); #ifdef MLN_RECREATE_GL_IN_AN_EMERGENCY -private: - void emergencyRecreateGL(); + private: + void emergencyRecreateGL(); #endif - // Implementation of mbgl::gfx::RendererBackend -public: - mbgl::gfx::Renderable& getDefaultRenderable() override { - return *this; - } + // Implementation of mbgl::gfx::RendererBackend + public: + mbgl::gfx::Renderable& getDefaultRenderable() override { return *this; } -private: - void activate() override; - void deactivate() override; - // End implementation of mbgl::gfx::RendererBackend + private: + void activate() override; + void deactivate() override; + // End implementation of mbgl::gfx::RendererBackend - // Implementation of mbgl::gl::RendererBackend -public: - void updateAssumedState() override; + // Implementation of mbgl::gl::RendererBackend + public: + void updateAssumedState() override; -private: - mbgl::gl::ProcAddress getExtensionFunctionPointer(const char* name) override; - // End implementation of mbgl::gl::Rendererbackend + private: + mbgl::gl::ProcAddress getExtensionFunctionPointer(const char* name) override; + // End implementation of mbgl::gl::Rendererbackend - // Implementation of MLNMapViewImpl -public: - mbgl::gfx::RendererBackend& getRendererBackend() override { - return *this; - } + // Implementation of MLNMapViewImpl + public: + mbgl::gfx::RendererBackend& getRendererBackend() override { return *this; } - EAGLContext* getEAGLContext() override; - void setOpaque(bool) override; - void display() override; - void setPresentsWithTransaction(bool) override; - void createView() override; - UIView* getView() override; - void deleteView() override; - UIImage* snapshot() override; - void layoutChanged() override; - MLNBackendResource getObject() override; - // End implementation of MLNMapViewImpl + EAGLContext* getEAGLContext() override; + void setOpaque(bool) override; + void display() override; + void setPresentsWithTransaction(bool) override; + void createView() override; + UIView* getView() override; + void deleteView() override; + UIImage* snapshot() override; + void layoutChanged() override; + MLNBackendResource getObject() override; + // End implementation of MLNMapViewImpl }; diff --git a/platform/ios/src/MLNMapView.h b/platform/ios/src/MLNMapView.h index 2ad755d60..daeba3059 100644 --- a/platform/ios/src/MLNMapView.h +++ b/platform/ios/src/MLNMapView.h @@ -1,12 +1,12 @@ #import +#import "MLNBackendResource.h" #import "MLNCompassButton.h" #import "MLNFoundation.h" #import "MLNGeometry.h" #import "MLNMapCamera.h" -#import "MLNTypes.h" #import "MLNStyle.h" -#import "MLNBackendResource.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -42,12 +42,12 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewDecelerationRate MLNMapViewDecelera `MLNMapView.userLocationVerticalAlignment`. */ typedef NS_ENUM(NSUInteger, MLNAnnotationVerticalAlignment) { - /** Aligns the annotation vertically in the center of the map view. */ - MLNAnnotationVerticalAlignmentCenter = 0, - /** Aligns the annotation vertically at the top of the map view. */ - MLNAnnotationVerticalAlignmentTop, - /** Aligns the annotation vertically at the bottom of the map view. */ - MLNAnnotationVerticalAlignmentBottom, + /** Aligns the annotation vertically in the center of the map view. */ + MLNAnnotationVerticalAlignmentCenter = 0, + /** Aligns the annotation vertically at the top of the map view. */ + MLNAnnotationVerticalAlignmentTop, + /** Aligns the annotation vertically at the bottom of the map view. */ + MLNAnnotationVerticalAlignmentBottom, }; /** @@ -58,14 +58,14 @@ typedef NS_ENUM(NSUInteger, MLNAnnotationVerticalAlignment) { `MLNMapView.attributionButtonPosition`. */ typedef NS_ENUM(NSUInteger, MLNOrnamentPosition) { - /** Place the ornament in the top left of the map view. */ - MLNOrnamentPositionTopLeft = 0, - /** Place the ornament in the top right of the map view. */ - MLNOrnamentPositionTopRight, - /** Place the ornament in the bottom left of the map view. */ - MLNOrnamentPositionBottomLeft, - /** Place the ornament in the bottom right of the map view. */ - MLNOrnamentPositionBottomRight, + /** Place the ornament in the top left of the map view. */ + MLNOrnamentPositionTopLeft = 0, + /** Place the ornament in the top right of the map view. */ + MLNOrnamentPositionTopRight, + /** Place the ornament in the bottom left of the map view. */ + MLNOrnamentPositionBottomLeft, + /** Place the ornament in the bottom right of the map view. */ + MLNOrnamentPositionBottomRight, }; /** @@ -77,42 +77,42 @@ typedef NS_ENUM(NSUInteger, MLNOrnamentPosition) { how each mode behaves. */ typedef NS_ENUM(NSUInteger, MLNUserTrackingMode) { - /** The map does not follow the user location. */ - MLNUserTrackingModeNone = 0, - /** The map follows the user location. This tracking mode falls back - to `MLNUserTrackingModeNone` if the user pans the map view. */ - MLNUserTrackingModeFollow, - /** - The map follows the user location and rotates when the heading changes. - The default user location annotation displays a fan-shaped indicator with - the current heading. The heading indicator represents the direction the - device is facing, which is sized according to the reported accuracy. + /** The map does not follow the user location. */ + MLNUserTrackingModeNone = 0, + /** The map follows the user location. This tracking mode falls back + to `MLNUserTrackingModeNone` if the user pans the map view. */ + MLNUserTrackingModeFollow, + /** + The map follows the user location and rotates when the heading changes. + The default user location annotation displays a fan-shaped indicator with + the current heading. The heading indicator represents the direction the + device is facing, which is sized according to the reported accuracy. - This tracking mode is disabled if the user pans the map view, but - remains enabled if the user zooms in. If the user rotates the map - view, this tracking mode will fall back to `MLNUserTrackingModeFollow`. - */ - MLNUserTrackingModeFollowWithHeading, - /** - The map follows the user location and rotates when the course changes. - Course represents the direction in which the device is traveling. - The default user location annotation shows a puck-shaped indicator - that rotates as the course changes. + This tracking mode is disabled if the user pans the map view, but + remains enabled if the user zooms in. If the user rotates the map + view, this tracking mode will fall back to `MLNUserTrackingModeFollow`. + */ + MLNUserTrackingModeFollowWithHeading, + /** + The map follows the user location and rotates when the course changes. + Course represents the direction in which the device is traveling. + The default user location annotation shows a puck-shaped indicator + that rotates as the course changes. - This tracking mode is disabled if the user pans the map view, but - remains enabled if the user zooms in. If the user rotates the map view, - this tracking mode will fall back to `MLNUserTrackingModeFollow`. - */ - MLNUserTrackingModeFollowWithCourse, + This tracking mode is disabled if the user pans the map view, but + remains enabled if the user zooms in. If the user rotates the map view, + this tracking mode will fall back to `MLNUserTrackingModeFollow`. + */ + MLNUserTrackingModeFollowWithCourse, }; typedef NS_ENUM(NSUInteger, MLNPanScrollingMode) { - /** The map allows the user to only scroll horizontally. */ - MLNPanScrollingModeHorizontal = 0, - /** The map allows the user to only scroll vertically. */ - MLNPanScrollingModeVertical, - /** The map allows the user to scroll both horizontally and vertically. */ - MLNPanScrollingModeDefault + /** The map allows the user to only scroll horizontally. */ + MLNPanScrollingModeHorizontal = 0, + /** The map allows the user to only scroll vertically. */ + MLNPanScrollingModeVertical, + /** The map allows the user to scroll both horizontally and vertically. */ + MLNPanScrollingModeDefault }; /** Options for `MLNMapView.preferredFramesPerSecond`. */ @@ -122,15 +122,19 @@ typedef NSInteger MLNMapViewPreferredFramesPerSecond NS_TYPED_EXTENSIBLE_ENUM; The default frame rate. This can be either 30 FPS or 60 FPS, depending on device capabilities. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewPreferredFramesPerSecond MLNMapViewPreferredFramesPerSecondDefault; +FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewPreferredFramesPerSecond + MLNMapViewPreferredFramesPerSecondDefault; /** A conservative frame rate; typically 30 FPS. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewPreferredFramesPerSecond MLNMapViewPreferredFramesPerSecondLowPower; +FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewPreferredFramesPerSecond + MLNMapViewPreferredFramesPerSecondLowPower; /** The maximum supported frame rate; typically 60 FPS. */ -FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewPreferredFramesPerSecond MLNMapViewPreferredFramesPerSecondMaximum; +FOUNDATION_EXTERN MLN_EXPORT const MLNMapViewPreferredFramesPerSecond + MLNMapViewPreferredFramesPerSecondMaximum; -FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNMissingLocationServicesUsageDescriptionException; +FOUNDATION_EXTERN MLN_EXPORT + MLNExceptionName const MLNMissingLocationServicesUsageDescriptionException; FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNUserLocationAnnotationTypeException; /** @@ -161,9 +165,9 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNUserLocationAnnotationTyp tap gesture fails: ```swift - let mapTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(myCustomFunction)) - for recognizer in mapView.gestureRecognizers! where recognizer is UITapGestureRecognizer { - mapTapGestureRecognizer.require(toFail: recognizer) + let mapTapGestureRecognizer = UITapGestureRecognizer(target: self, action: + #selector(myCustomFunction)) for recognizer in mapView.gestureRecognizers! where recognizer is + UITapGestureRecognizer { mapTapGestureRecognizer.require(toFail: recognizer) } mapView.addGestureRecognizer(mapTapGestureRecognizer) ``` @@ -196,7 +200,7 @@ MLN_EXPORT @return An initialized map view. #### Related examples - + - TODO: initialize an `MLNMapView` with a custom style - TODO: how to initialize an `MLNMapView` with a third-party tile source */ @@ -212,7 +216,7 @@ MLN_EXPORT annotations displayed on the map, such as the styles to apply to individual annotations. */ -@property(nonatomic, weak, nullable) IBOutlet id delegate; +@property (nonatomic, weak, nullable) IBOutlet id delegate; // MARK: Configuring the Map’s Appearance @@ -263,11 +267,11 @@ MLN_EXPORT /** A boolean value that indicates if whether the map view should automatically adjust its content insets. - + When this property is set to `YES` the map automatically updates its `contentInset` property to account for any area not covered by navigation bars, tab bars, toolbars, and other ancestors that obscure the map view. - + */ @property (assign) BOOL automaticallyAdjustsContentInset; @@ -345,7 +349,6 @@ MLN_EXPORT */ @property (nonatomic, assign) CGPoint logoViewMargins; - /** A view showing legally required copyright notices, positioned at the bottom-right of the map view. @@ -397,12 +400,12 @@ MLN_EXPORT /** A Boolean value indicating whether the map should prefetch tiles. - + When this property is set to `YES`, the map view prefetches tiles designed for a low zoom level and displays them until receiving more detailed tiles for the current zoom level. The prefetched tiles typically contain simplified versions of each shape, improving the map view’s perceived performance. - + The default value of this property is `YES`. */ @property (nonatomic, assign) BOOL prefetchesTiles; @@ -454,7 +457,7 @@ MLN_EXPORT Setting this property to `YES` causes the map view to use the Core Location framework to request authorization when authorizationStatus == kCLAuthorizationStatusNotDetermined. - + The default value of this property is `YES`. */ @property (nonatomic, assign) BOOL shouldRequestAuthorizationToUseLocationServices; @@ -489,7 +492,7 @@ MLN_EXPORT /** Deprecated. Sets the mode used to track the user location, with an optional transition. - + To specify a completion handler to execute after the animation finishes, use the `-setUserTrackingMode:animated:completionHandler:` method. @@ -500,7 +503,9 @@ MLN_EXPORT affects the initial transition; subsequent changes to the user location or heading are always animated. */ -- (void)setUserTrackingMode:(MLNUserTrackingMode)mode animated:(BOOL)animated __attribute__((deprecated("Use `-setUserTrackingMode:animated:completionHandler:` instead."))); +- (void)setUserTrackingMode:(MLNUserTrackingMode)mode + animated:(BOOL)animated + __attribute__((deprecated("Use `-setUserTrackingMode:animated:completionHandler:` instead."))); /** Sets the mode used to track the user location, with an optional transition and @@ -514,7 +519,9 @@ MLN_EXPORT heading are always animated. @param completion The block executed after the animation finishes. */ -- (void)setUserTrackingMode:(MLNUserTrackingMode)mode animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setUserTrackingMode:(MLNUserTrackingMode)mode + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** The vertical alignment of the user location annotation within the receiver. The @@ -524,7 +531,9 @@ MLN_EXPORT transition. If you don’t want to animate the change, use the `-setUserLocationVerticalAlignment:animated:` method instead. */ -@property (nonatomic, assign) MLNAnnotationVerticalAlignment userLocationVerticalAlignment __attribute__((deprecated("Use `-[MLNMapViewDelegate mapViewUserLocationAnchorPoint:]` instead."))); +@property (nonatomic, assign) MLNAnnotationVerticalAlignment userLocationVerticalAlignment + __attribute__(( + deprecated("Use `-[MLNMapViewDelegate mapViewUserLocationAnchorPoint:]` instead."))); /** Sets the vertical alignment of the user location annotation within the @@ -535,7 +544,10 @@ MLN_EXPORT position within the map view. If `NO`, the user location annotation instantaneously moves to its new position. */ -- (void)setUserLocationVerticalAlignment:(MLNAnnotationVerticalAlignment)alignment animated:(BOOL)animated __attribute__((deprecated("Use `-[MLNMapViewDelegate mapViewUserLocationAnchorPoint:]` instead."))); +- (void)setUserLocationVerticalAlignment:(MLNAnnotationVerticalAlignment)alignment + animated:(BOOL)animated + __attribute__(( + deprecated("Use `-[MLNMapViewDelegate mapViewUserLocationAnchorPoint:]` instead."))); /** Updates the position of the user location annotation view by retreiving the user's last @@ -606,7 +618,7 @@ MLN_EXPORT This method has no effect if the `userTrackingMode` property is set to a value other than `MLNUserTrackingModeFollowWithCourse`. - + To specify a completion handler to execute after the animation finishes, use the `-setTargetCoordinate:animated:completionHandler:` method. @@ -614,7 +626,9 @@ MLN_EXPORT @param animated If `YES`, the map animates to fit the target within the map view. If `NO`, the map fits the target instantaneously. */ -- (void)setTargetCoordinate:(CLLocationCoordinate2D)targetCoordinate animated:(BOOL)animated __attribute__((deprecated("Use `-setTargetCoordinate:animated:completionHandler:` instead."))); +- (void)setTargetCoordinate:(CLLocationCoordinate2D)targetCoordinate + animated:(BOOL)animated + __attribute__((deprecated("Use `-setTargetCoordinate:animated:completionHandler:` instead."))); /** Sets the geographic coordinate that is the subject of observation as the user @@ -636,7 +650,9 @@ MLN_EXPORT view. If `NO`, the map fits the target instantaneously. @param completion The block executed after the animation finishes. */ -- (void)setTargetCoordinate:(CLLocationCoordinate2D)targetCoordinate animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setTargetCoordinate:(CLLocationCoordinate2D)targetCoordinate + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; // MARK: Configuring How the User Interacts with the Map @@ -652,7 +668,7 @@ MLN_EXPORT value of this property to `NO`, you may still change the map zoom programmatically. */ -@property(nonatomic, getter=isZoomEnabled) BOOL zoomEnabled; +@property (nonatomic, getter=isZoomEnabled) BOOL zoomEnabled; /** A Boolean value that determines whether the user may scroll around the map, @@ -665,7 +681,7 @@ MLN_EXPORT value of this property to `NO`, you may still change the map location programmatically. */ -@property(nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; +@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled; /** The scrolling mode the user is allowed to use to interact with the map. @@ -692,7 +708,7 @@ MLN_EXPORT value of this property to `NO`, you may still rotate the map programmatically. */ -@property(nonatomic, getter=isRotateEnabled) BOOL rotateEnabled; +@property (nonatomic, getter=isRotateEnabled) BOOL rotateEnabled; /** A Boolean value that determines whether the user may change the pitch (tilt) of @@ -707,13 +723,13 @@ MLN_EXPORT The default value of this property is `YES`. */ -@property(nonatomic, getter=isPitchEnabled) BOOL pitchEnabled; +@property (nonatomic, getter=isPitchEnabled) BOOL pitchEnabled; /** - A Boolean value that determines whether gestures are anchored to the center coordinate of the map while rotating or zooming. - Default value is set to NO. + A Boolean value that determines whether gestures are anchored to the center coordinate of the map + while rotating or zooming. Default value is set to NO. */ -@property(nonatomic) BOOL anchorRotateOrZoomGesturesToCenterCoordinate; +@property (nonatomic) BOOL anchorRotateOrZoomGesturesToCenterCoordinate; /** A Boolean value that determines whether the user will receive haptic feedback @@ -726,7 +742,7 @@ MLN_EXPORT This feature requires a device that supports haptic feedback, running iOS 10 or newer. */ -@property(nonatomic, getter=isHapticFeedbackEnabled) BOOL hapticFeedbackEnabled; +@property (nonatomic, getter=isHapticFeedbackEnabled) BOOL hapticFeedbackEnabled; /** A floating-point value that determines the rate of deceleration after the user @@ -737,7 +753,7 @@ MLN_EXPORT deceleration rates. `MLNMapViewDecelerationRateImmediate` can be used to disable deceleration entirely. */ -@property(nonatomic) CGFloat decelerationRate; +@property (nonatomic) CGFloat decelerationRate; // MARK: Manipulating the Viewpoint @@ -757,7 +773,7 @@ MLN_EXPORT Changes the center coordinate of the map and optionally animates the change. Changing the center coordinate centers the map on the new coordinate without - changing the current zoom level. For animated changes, wait until the map view has + changing the current zoom level. For animated changes, wait until the map view has finished loading before calling this method. @param coordinate The new center coordinate for the map. @@ -772,7 +788,7 @@ MLN_EXPORT /** Changes the center coordinate and zoom level of the map and optionally animates - the change. For animated changes, wait until the map view has + the change. For animated changes, wait until the map view has finished loading before calling this method. @param centerCoordinate The new center coordinate for the map. @@ -784,11 +800,13 @@ MLN_EXPORT @note The behavior of this method is undefined if called in response to `UIApplicationWillTerminateNotification`. */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel animated:(BOOL)animated; +- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate + zoomLevel:(double)zoomLevel + animated:(BOOL)animated; /** Changes the center coordinate, zoom level, and direction of the map and - optionally animates the change. For animated changes, wait until the map view has + optionally animates the change. For animated changes, wait until the map view has finished loading before calling this method. @param centerCoordinate The new center coordinate for the map. @@ -802,11 +820,14 @@ MLN_EXPORT @note The behavior of this method is undefined if called in response to `UIApplicationWillTerminateNotification`. */ -- (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; /** Changes the center coordinate, zoom level, and direction of the map, calling a - completion handler at the end of an optional animation. For animated changes, + completion handler at the end of an optional animation. For animated changes, wait until the map view has finished loading before calling this method. @param centerCoordinate The new center coordinate for the map. @@ -821,7 +842,11 @@ MLN_EXPORT @note The behavior of this method is undefined if called in response to `UIApplicationWillTerminateNotification`. */ -- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate + zoomLevel:(double)zoomLevel + direction:(CLLocationDirection)direction + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** The zoom level of the receiver. @@ -973,7 +998,7 @@ MLN_EXPORT specify some longitudes less than −180 degrees or greater than 180 degrees. For example, to show both Tokyo and San Francisco simultaneously, you could set the visible bounds to extend from (35.68476, −220.24257) to (37.78428, −122.41310). - + To specify a completion handler to execute after the animation finishes, use the `-setVisibleCoordinateBounds:edgePadding:animated:completionHandler:` method. @@ -983,7 +1008,11 @@ MLN_EXPORT @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. */ -- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated __attribute__((deprecated("Use `-setVisibleCoordinateBounds:edgePadding:animated:completionHandler:` instead."))); +- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(UIEdgeInsets)insets + animated:(BOOL)animated + __attribute__((deprecated( + "Use `-setVisibleCoordinateBounds:edgePadding:animated:completionHandler:` instead."))); /** Changes the receiver’s viewport to fit the given coordinate bounds with some @@ -1001,7 +1030,10 @@ MLN_EXPORT zooming or `NO` to immediately display the given bounds. @param completion The block executed after the animation finishes. */ -- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(UIEdgeInsets)insets + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** Changes the receiver’s viewport to fit all of the given coordinates with some @@ -1020,7 +1052,10 @@ MLN_EXPORT @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. */ -- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates count:(NSUInteger)count edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated; +- (void)setVisibleCoordinates:(const CLLocationCoordinate2D *)coordinates + count:(NSUInteger)count + edgePadding:(UIEdgeInsets)insets + animated:(BOOL)animated; /** Changes the receiver’s viewport to fit all of the given coordinates with some @@ -1043,7 +1078,13 @@ MLN_EXPORT @param function The timing function to animate the change. @param completion The block executed after the animation finishes. */ -- (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; +- (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; /** Sets the visible region so that the map displays the specified annotations. @@ -1057,7 +1098,7 @@ MLN_EXPORT @param animated `YES` if you want the map region change to be animated, or `NO` if you want the map to display the new region immediately without animations. */ -- (void)showAnnotations:(NSArray> *)annotations animated:(BOOL)animated; +- (void)showAnnotations:(NSArray> *)annotations animated:(BOOL)animated; /** Deprecated. Sets the visible region so that the map displays the specified @@ -1065,7 +1106,7 @@ MLN_EXPORT Calling this method updates the value in the `visibleCoordinateBounds` property and potentially other properties to reflect the new map region. - + To specify a completion handler to execute after the animation finishes, use the `-showAnnotations:edgePadding:animated:completionHandler:` method. @@ -1075,7 +1116,11 @@ MLN_EXPORT @param animated `YES` if you want the map region change to be animated, or `NO` if you want the map to display the new region immediately without animations. */ -- (void)showAnnotations:(NSArray> *)annotations edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated __attribute__((deprecated("Use `-showAnnotations:edgePadding:animated:completionHandler:` instead."))); +- (void)showAnnotations:(NSArray> *)annotations + edgePadding:(UIEdgeInsets)insets + animated:(BOOL)animated + __attribute__(( + deprecated("Use `-showAnnotations:edgePadding:animated:completionHandler:` instead."))); /** Sets the visible region so that the map displays the specified annotations with @@ -1092,7 +1137,10 @@ MLN_EXPORT if you want the map to display the new region immediately without animations. @param completion The block executed after the animation finishes. */ -- (void)showAnnotations:(NSArray> *)annotations edgePadding:(UIEdgeInsets)insets animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)showAnnotations:(NSArray> *)annotations + edgePadding:(UIEdgeInsets)insets + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** A camera representing the current viewpoint of the map. @@ -1101,7 +1149,7 @@ MLN_EXPORT /** Moves the viewpoint to a different location with respect to the map with an - optional transition animation. For animated changes, wait until the map view has + optional transition animation. For animated changes, wait until the map view has finished loading before calling this method. @param camera The new viewpoint. @@ -1116,7 +1164,7 @@ MLN_EXPORT /** Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. For animated changes, wait + optional transition duration and timing function. For animated changes, wait until the map view has finished loading before calling this method. @param camera The new viewpoint. @@ -1131,11 +1179,13 @@ MLN_EXPORT - TODO: Camera animation: learn how to create a timed animation that rotates around a central point for a specific duration. */ -- (void)setCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function; +- (void)setCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + animationTimingFunction:(nullable CAMediaTimingFunction *)function; /** Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function. For animated changes, wait + optional transition duration and timing function. For animated changes, wait until the map view has finished loading before calling this method. @param camera The new viewpoint. @@ -1147,12 +1197,15 @@ MLN_EXPORT is `0`, this parameter is ignored. @param completion The block to execute after the animation finishes. */ -- (void)setCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion; +- (void)setCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + animationTimingFunction:(nullable CAMediaTimingFunction *)function + completionHandler:(nullable void (^)(void))completion; /** Moves the viewpoint to a different location with respect to the map with an optional transition duration and timing function, and optionally some additional - padding on each side. For animated changes, wait until the map view has + padding on each side. For animated changes, wait until the map view has finished loading before calling this method. @param camera The new viewpoint. @@ -1166,7 +1219,11 @@ MLN_EXPORT around the returned camera object if it were set as the receiver’s camera. @param completion The block to execute after the animation finishes. */ -- (void)setCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function edgePadding:(UIEdgeInsets)edgePadding completionHandler:(nullable void (^)(void))completion; +- (void)setCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + animationTimingFunction:(nullable CAMediaTimingFunction *)function + edgePadding:(UIEdgeInsets)edgePadding + completionHandler:(nullable void (^)(void))completion; /** Moves the viewpoint to a different location using a transition animation that @@ -1195,7 +1252,9 @@ MLN_EXPORT is based on the length of the flight path. @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion; +- (void)flyToCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + completionHandler:(nullable void (^)(void))completion; /** Moves the viewpoint to a different location using a transition animation that @@ -1215,8 +1274,10 @@ MLN_EXPORT `-setCamera:animated:` would have a midpoint at a higher altitude. @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion; - +- (void)flyToCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + peakAltitude:(CLLocationDistance)peakAltitude + completionHandler:(nullable void (^)(void))completion; /** Moves the viewpoint to a different location using a transition animation that @@ -1234,7 +1295,10 @@ MLN_EXPORT around the returned camera object if it were set as the receiver’s camera. @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MLNMapCamera *)camera edgePadding:(UIEdgeInsets)insets withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion; +- (void)flyToCamera:(MLNMapCamera *)camera + edgePadding:(UIEdgeInsets)insets + withDuration:(NSTimeInterval)duration + completionHandler:(nullable void (^)(void))completion; /** Returns the camera that best fits the given coordinate bounds. @@ -1267,7 +1331,8 @@ MLN_EXPORT `UIApplicationWillTerminateNotification`; you may receive a `nil` return value depending on the order of notification delivery. */ -- (MLNMapCamera *)cameraThatFitsCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets; +- (MLNMapCamera *)cameraThatFitsCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(UIEdgeInsets)insets; /** Returns the camera that best fits the given coordinate bounds with some @@ -1288,7 +1353,9 @@ MLN_EXPORT `UIApplicationWillTerminateNotification`; you may receive a `nil` return value depending on the order of notification delivery. */ -- (MLNMapCamera *)camera:(MLNMapCamera *)camera fittingCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets; +- (MLNMapCamera *)camera:(MLNMapCamera *)camera + fittingCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(UIEdgeInsets)insets; /** Returns the camera that best fits the given shape with some additional padding @@ -1307,7 +1374,9 @@ MLN_EXPORT `UIApplicationWillTerminateNotification`; you may receive a `nil` return value depending on the order of notification delivery. */ -- (MLNMapCamera *)camera:(MLNMapCamera *)camera fittingShape:(MLNShape *)shape edgePadding:(UIEdgeInsets)insets; +- (MLNMapCamera *)camera:(MLNMapCamera *)camera + fittingShape:(MLNShape *)shape + edgePadding:(UIEdgeInsets)insets; /** Returns the camera that best fits the given shape with some additional padding @@ -1326,7 +1395,9 @@ MLN_EXPORT `UIApplicationWillTerminateNotification`; you may receive a `nil` return value depending on the order of notification delivery. */ -- (MLNMapCamera *)cameraThatFitsShape:(MLNShape *)shape direction:(CLLocationDirection)direction edgePadding:(UIEdgeInsets)insets; +- (MLNMapCamera *)cameraThatFitsShape:(MLNShape *)shape + direction:(CLLocationDirection)direction + edgePadding:(UIEdgeInsets)insets; /** Returns the point in this view’s coordinate system on which to “anchor” in @@ -1356,11 +1427,11 @@ MLN_EXPORT view’s frame. Otherwise, those properties are inset, excluding part of the frame from the viewport. For instance, if the only the top edge is inset, the map center is effectively shifted downward. - + When the map view’s superview is an instance of `UIViewController` whose `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this property may be overridden at any time. - + The usage of `automaticallyAdjustsScrollViewInsets` has been deprecated use the map view’s property `MLNMapView.automaticallyAdjustsContentInset`instead. @@ -1396,10 +1467,10 @@ MLN_EXPORT When the map view’s superview is an instance of `UIViewController` whose `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this property may be overridden at any time. - + The usage of `automaticallyAdjustsScrollViewInsets` has been deprecated use the map view’s property `MLNMapView.automaticallyAdjustsContentInset`instead. - + To specify a completion handler to execute after the animation finishes, use the `-setContentInset:animated:completionHandler:` method. @@ -1408,7 +1479,9 @@ MLN_EXPORT the content inset or `NO` if you want the map to inset the content immediately. */ -- (void)setContentInset:(UIEdgeInsets)contentInset animated:(BOOL)animated __attribute__((deprecated("Use `-setContentInset:animated:completionHandler:` instead."))); +- (void)setContentInset:(UIEdgeInsets)contentInset + animated:(BOOL)animated + __attribute__((deprecated("Use `-setContentInset:animated:completionHandler:` instead."))); /** Sets the distance from the edges of the map view’s frame to the edges of the @@ -1424,7 +1497,7 @@ MLN_EXPORT When the map view’s superview is an instance of `UIViewController` whose `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this property may be overridden at any time. - + The usage of `automaticallyAdjustsScrollViewInsets` has been deprecated use the map view’s property `MLNMapView.automaticallyAdjustsContentInset`instead. @@ -1434,7 +1507,9 @@ MLN_EXPORT immediately. @param completion The block executed after the animation finishes. */ -- (void)setContentInset:(UIEdgeInsets)contentInset animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setContentInset:(UIEdgeInsets)contentInset + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; // MARK: Converting Geographic Coordinates @@ -1466,7 +1541,8 @@ MLN_EXPORT #### Related examples - TODO: Point conversion: learn how to convert a map coordinate to a `CGPoint` object. */ -- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable UIView *)view; +- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate + toPointToView:(nullable UIView *)view; /** Converts a rectangle in the given view’s coordinate system to a geographic @@ -1517,7 +1593,7 @@ MLN_EXPORT Returns the new map projection instance initialized with the map view, i.e. with the current camera state. */ -- (MLNMapProjection*)mapProjection; +- (MLNMapProjection *)mapProjection; // MARK: Annotating the Map @@ -1528,7 +1604,7 @@ MLN_EXPORT annotations are associated with the map view, the value of this property is `nil`. */ -@property (nonatomic, readonly, nullable) NSArray> *annotations; +@property (nonatomic, readonly, nullable) NSArray> *annotations; /** Adds an annotation to the map view. @@ -1546,7 +1622,7 @@ MLN_EXPORT - TODO: add a line annotation from GeoJSON. - TODO: add an annotation to an `MLNMapView` object. */ -- (void)addAnnotation:(id )annotation; +- (void)addAnnotation:(id)annotation; /** Adds an array of annotations to the map view. @@ -1561,7 +1637,7 @@ MLN_EXPORT must conform to the `MLNAnnotation` protocol. The map view retains each individual annotation object. */ -- (void)addAnnotations:(NSArray> *)annotations; +- (void)addAnnotations:(NSArray> *)annotations; /** Removes an annotation from the map view, deselecting it if it is selected. @@ -1573,7 +1649,7 @@ MLN_EXPORT @param annotation The annotation object to remove. This object must conform to the `MLNAnnotation` protocol */ -- (void)removeAnnotation:(id )annotation; +- (void)removeAnnotation:(id)annotation; /** Removes an array of annotations from the map view, deselecting any selected @@ -1586,7 +1662,7 @@ MLN_EXPORT @param annotations The array of annotation objects to remove. Objects in the array must conform to the `MLNAnnotation` protocol. */ -- (void)removeAnnotations:(NSArray> *)annotations; +- (void)removeAnnotations:(NSArray> *)annotations; /** Returns an `MLNAnnotationView` if the given annotation is currently associated @@ -1595,7 +1671,7 @@ MLN_EXPORT @param annotation The annotation associated with the view. Annotation must conform to the `MLNAnnotation` protocol. */ -- (nullable MLNAnnotationView *)viewForAnnotation:(id )annotation; +- (nullable MLNAnnotationView *)viewForAnnotation:(id)annotation; /** Returns a reusable annotation image object associated with its identifier. @@ -1615,7 +1691,8 @@ MLN_EXPORT - TODO: Add annotation views and images: learn how to most efficiently reuse an `MLNAnnotationImage`. */ -- (nullable __kindof MLNAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier:(NSString *)identifier; +- (nullable __kindof MLNAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier: + (NSString *)identifier; /** Returns a reusable annotation view object associated with its identifier. @@ -1631,7 +1708,8 @@ MLN_EXPORT @return An annotation view object with the given identifier, or `nil` if no such object exists in the reuse queue. */ -- (nullable __kindof MLNAnnotationView *)dequeueReusableAnnotationViewWithIdentifier:(NSString *)identifier; +- (nullable __kindof MLNAnnotationView *)dequeueReusableAnnotationViewWithIdentifier: + (NSString *)identifier; /** The complete list of annotations associated with the receiver that are @@ -1641,7 +1719,7 @@ MLN_EXPORT annotations are associated with the map view or if no annotations associated with the map view are currently visible, the value of this property is `nil`. */ -@property (nonatomic, readonly, nullable) NSArray> *visibleAnnotations; +@property (nonatomic, readonly, nullable) NSArray> *visibleAnnotations; /** Returns the list of annotations associated with the receiver that intersect with @@ -1652,7 +1730,7 @@ MLN_EXPORT no annotations associated with the map view are currently visible in the rectangle. */ -- (nullable NSArray> *)visibleAnnotationsInRect:(CGRect)rect; +- (nullable NSArray> *)visibleAnnotationsInRect:(CGRect)rect; // MARK: Managing Annotation Selections @@ -1669,7 +1747,7 @@ MLN_EXPORT @note In versions prior to `4.0.0` if the annotation was offscreen it was not selected. */ -@property (nonatomic, copy) NSArray> *selectedAnnotations; +@property (nonatomic, copy) NSArray> *selectedAnnotations; /** Deprecated. Selects an annotation and displays its callout view. @@ -1679,11 +1757,15 @@ MLN_EXPORT | `animated` parameter | Effect | |------------------|--------| - | `NO` | The annotation is selected, and the callout is presented. However the map is not panned to bring the annotation or callout into view. The presentation of the callout is NOT animated. | - | `YES` | The annotation is selected, and the callout is presented. If the annotation is not visible (or is partially visible) *and* is of type `MLNPointAnnotation`, the map is panned so that the annotation and its callout are brought into view. The annotation is *not* centered within the viewport. | + | `NO` | The annotation is selected, and the callout is presented. However the map is + not panned to bring the annotation or callout into view. The presentation of the callout is NOT + animated. | | `YES` | The annotation is selected, and the callout is presented. If the + annotation is not visible (or is partially visible) *and* is of type `MLNPointAnnotation`, the map + is panned so that the annotation and its callout are brought into view. The annotation is *not* + centered within the viewport. | Note that a selection initiated by a single tap gesture is always animated. - + To specify a completion handler to execute after the animation finishes, use the `-selectAnnotation:animated:completionHandler:` method. @@ -1693,7 +1775,9 @@ MLN_EXPORT @note In versions prior to `4.0.0` selecting an offscreen annotation did not change the camera. */ -- (void)selectAnnotation:(id )annotation animated:(BOOL)animated __attribute__((deprecated("Use `-selectAnnotation:animated:completionHandler:` instead."))); +- (void)selectAnnotation:(id)annotation + animated:(BOOL)animated + __attribute__((deprecated("Use `-selectAnnotation:animated:completionHandler:` instead."))); /** Selects an annotation and displays its callout view with an optional completion @@ -1704,8 +1788,12 @@ MLN_EXPORT | `animated` parameter | Effect | |------------------|--------| - | `NO` | The annotation is selected, and the callout is presented. However the map is not panned to bring the annotation or callout into view. The presentation of the callout is NOT animated. | - | `YES` | The annotation is selected, and the callout is presented. If the annotation is not visible (or is partially visible) *and* is of type `MLNPointAnnotation`, the map is panned so that the annotation and its callout are brought into view. The annotation is *not* centered within the viewport. | + | `NO` | The annotation is selected, and the callout is presented. However the map is + not panned to bring the annotation or callout into view. The presentation of the callout is NOT + animated. | | `YES` | The annotation is selected, and the callout is presented. If the + annotation is not visible (or is partially visible) *and* is of type `MLNPointAnnotation`, the map + is panned so that the annotation and its callout are brought into view. The annotation is *not* + centered within the viewport. | Note that a selection initiated by a single tap gesture is always animated. @@ -1716,7 +1804,9 @@ MLN_EXPORT @note In versions prior to `4.0.0` selecting an offscreen annotation did not change the camera. */ -- (void)selectAnnotation:(id )annotation animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)selectAnnotation:(id)annotation + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** :nodoc: @@ -1725,11 +1815,17 @@ MLN_EXPORT change. @param annotation The annotation object to select. - @param moveIntoView If the annotation is not visible (or is partially visible) *and* is of type `MLNPointAnnotation`, the map is panned so that the annotation and its callout are brought into view. The annotation is *not* centered within the viewport. - @param animateSelection If `YES`, the annotation's selection state and callout view's presentation are animated. + @param moveIntoView If the annotation is not visible (or is partially visible) *and* is of type + `MLNPointAnnotation`, the map is panned so that the annotation and its callout are brought into + view. The annotation is *not* centered within the viewport. + @param animateSelection If `YES`, the annotation's selection state and callout view's presentation + are animated. @param completion The block executed after the animation finishes. */ -- (void)selectAnnotation:(id )annotation moveIntoView:(BOOL)moveIntoView animateSelection:(BOOL)animateSelection completionHandler:(nullable void (^)(void))completion; +- (void)selectAnnotation:(id)annotation + moveIntoView:(BOOL)moveIntoView + animateSelection:(BOOL)animateSelection + completionHandler:(nullable void (^)(void))completion; /** Deselects an annotation and hides its callout view. @@ -1737,7 +1833,7 @@ MLN_EXPORT @param annotation The annotation object to deselect. @param animated If `YES`, the callout view is animated offscreen. */ -- (void)deselectAnnotation:(nullable id )annotation animated:(BOOL)animated; +- (void)deselectAnnotation:(nullable id)annotation animated:(BOOL)animated; // MARK: Overlaying the Map @@ -1748,7 +1844,7 @@ MLN_EXPORT overlays are associated with the map view, the value of this property is empty array. */ -@property (nonatomic, readonly, nonnull) NSArray> *overlays; +@property (nonatomic, readonly, nonnull) NSArray> *overlays; /** Adds a single overlay object to the map. @@ -1757,7 +1853,7 @@ MLN_EXPORT @param overlay The overlay object to add. This object must conform to the `MLNOverlay` protocol. */ -- (void)addOverlay:(id )overlay; +- (void)addOverlay:(id)overlay; /** Adds an array of overlay objects to the map. @@ -1767,7 +1863,7 @@ MLN_EXPORT @param overlays An array of objects, each of which must conform to the `MLNOverlay` protocol. */ -- (void)addOverlays:(NSArray> *)overlays; +- (void)addOverlays:(NSArray> *)overlays; /** Removes a single overlay object from the map. @@ -1777,7 +1873,7 @@ MLN_EXPORT @param overlay The overlay object to remove. */ -- (void)removeOverlay:(id )overlay; +- (void)removeOverlay:(id)overlay; /** Removes one or more overlay objects from the map. @@ -1787,7 +1883,7 @@ MLN_EXPORT @param overlays An array of objects, each of which conforms to the `MLNOverlay` protocol. */ -- (void)removeOverlays:(NSArray> *)overlays; +- (void)removeOverlays:(NSArray> *)overlays; // MARK: Accessing the Underlying Map Data @@ -1807,7 +1903,8 @@ MLN_EXPORT - TODO: Select a feature within a layer: to learn how to query an `MLNMapView` object for visible `MLNFeature` objects. */ -- (NSArray> *)visibleFeaturesAtPoint:(CGPoint)point NS_SWIFT_NAME(visibleFeatures(at:)); +- (NSArray> *)visibleFeaturesAtPoint:(CGPoint)point + NS_SWIFT_NAME(visibleFeatures(at:)); /** Returns an array of rendered map features that intersect with a given point, @@ -1826,7 +1923,10 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:)); +- (NSArray> *)visibleFeaturesAtPoint:(CGPoint)point + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:)); /** Returns an array of rendered map features that intersect with a given point, @@ -1893,7 +1993,11 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesAtPoint:(CGPoint)point inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:predicate:)); +- (NSArray> *)visibleFeaturesAtPoint:(CGPoint)point + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + predicate:(nullable NSPredicate *)predicate + NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:predicate:)); /** Returns an array of rendered map features that intersect with the given @@ -1908,7 +2012,7 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesInRect:(CGRect)rect NS_SWIFT_NAME(visibleFeatures(in:)); +- (NSArray> *)visibleFeaturesInRect:(CGRect)rect NS_SWIFT_NAME(visibleFeatures(in:)); /** Returns an array of rendered map features that intersect with the given @@ -1927,7 +2031,10 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:)); +- (NSArray> *)visibleFeaturesInRect:(CGRect)rect + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:)); /** Returns an array of rendered map features that intersect with the given @@ -1998,7 +2105,11 @@ MLN_EXPORT @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesInRect:(CGRect)rect inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:predicate:)); +- (NSArray> *)visibleFeaturesInRect:(CGRect)rect + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + predicate:(nullable NSPredicate *)predicate + NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:predicate:)); // MARK: Debugging the Map @@ -2010,7 +2121,6 @@ MLN_EXPORT */ @property (nonatomic) MLNMapDebugMaskOptions debugMask; - - (MLNBackendResource)backendResource; @end diff --git a/platform/ios/src/MLNMapViewDelegate.h b/platform/ios/src/MLNMapViewDelegate.h index e21c0e22a..216e089bd 100644 --- a/platform/ios/src/MLNMapViewDelegate.h +++ b/platform/ios/src/MLNMapViewDelegate.h @@ -1,7 +1,7 @@ #import -#import "Mapbox.h" #import "MLNCameraChangeReason.h" +#import "Mapbox.h" NS_ASSUME_NONNULL_BEGIN @@ -46,7 +46,9 @@ NS_ASSUME_NONNULL_BEGIN #### Related examples - */ -- (BOOL)mapView:(MLNMapView *)mapView shouldChangeFromCamera:(MLNMapCamera *)oldCamera toCamera:(MLNMapCamera *)newCamera; +- (BOOL)mapView:(MLNMapView *)mapView + shouldChangeFromCamera:(MLNMapCamera *)oldCamera + toCamera:(MLNMapCamera *)newCamera; /** :nodoc: @@ -65,14 +67,18 @@ NS_ASSUME_NONNULL_BEGIN gesture is recognized. If this method returns `NO`, the map view’s camera continues to be this camera. @param newCamera The expected camera after the gesture completes. If this - method returns `YES`, the viewport of the map will transition to the new camera. Note that the new camera cannot be modified. + method returns `YES`, the viewport of the map will transition to the new camera. Note that the new + camera cannot be modified. @param reason The reason for the camera change. @return A Boolean value indicating whether the map view should stay at `oldCamera` or transition to `newCamera`. @note If this method is implemented `-mapView:shouldChangeFromCamera:toCamera:` will not be called. */ -- (BOOL)mapView:(MLNMapView *)mapView shouldChangeFromCamera:(MLNMapCamera *)oldCamera toCamera:(MLNMapCamera *)newCamera reason:(MLNCameraChangeReason)reason; +- (BOOL)mapView:(MLNMapView *)mapView + shouldChangeFromCamera:(MLNMapCamera *)oldCamera + toCamera:(MLNMapCamera *)newCamera + reason:(MLNCameraChangeReason)reason; /** Tells the delegate that the viewpoint depicted by the map view is about to change. @@ -98,7 +104,9 @@ NS_ASSUME_NONNULL_BEGIN @note If this method is implemented `-mapView:regionWillChangeAnimated:` will not be called. */ -- (void)mapView:(MLNMapView *)mapView regionWillChangeWithReason:(MLNCameraChangeReason)reason animated:(BOOL)animated; +- (void)mapView:(MLNMapView *)mapView + regionWillChangeWithReason:(MLNCameraChangeReason)reason + animated:(BOOL)animated; /** Tells the delegate that the viewpoint depicted by the map view is changing. @@ -168,7 +176,9 @@ NS_ASSUME_NONNULL_BEGIN @note If this method is implemented `-mapView:regionDidChangeAnimated:` will not be called. */ -- (void)mapView:(MLNMapView *)mapView regionDidChangeWithReason:(MLNCameraChangeReason)reason animated:(BOOL)animated; +- (void)mapView:(MLNMapView *)mapView + regionDidChangeWithReason:(MLNCameraChangeReason)reason + animated:(BOOL)animated; // MARK: Loading the Map @@ -258,11 +268,11 @@ NS_ASSUME_NONNULL_BEGIN Tells the delegate that the map view is entering an idle state, and no more drawing will be necessary until new data is loaded or there is some interaction with the map. - + - No camera transitions are in progress - All currently requested tiles have loaded - All fade/transition animations have completed - + @param mapView The map view that has just entered the idle state. */ - (void)mapViewDidBecomeIdle:(MLNMapView *)mapView; @@ -290,7 +300,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style; /** - Tells the delegate that the `mapView` is missing an image. The image should be added synchronously with `-[MLNStyle setImage:forName:]` to be rendered on the current zoom level. When loading icons asynchronously, you can load a placeholder image and replace it when your image has loaded. + Tells the delegate that the `mapView` is missing an image. The image should be added synchronously + with `-[MLNStyle setImage:forName:]` to be rendered on the current zoom level. When loading icons + asynchronously, you can load a placeholder image and replace it when your image has loaded. @param mapView The map view that is loading the image. @param imageName The name of the image that is missing. @@ -299,11 +311,11 @@ NS_ASSUME_NONNULL_BEGIN /** Asks the delegate whether the map view should evict cached images. - + This method is called in two scenarios: when the cumulative size of unused images exceeds the cache size or when the last tile that includes the image is removed from memory. - + @param mapView The map view that is evicting the image. @param imageName The image name that is going to be removed. @return A Boolean value indicating whether the map view should evict @@ -335,13 +347,14 @@ NS_ASSUME_NONNULL_BEGIN /** Asks the delegate styling options for each default user location annotation view. - + This method is called many times during gesturing, so you should avoid performing complex or performance-intensive tasks in your implementation. - + @param mapView The map view that is tracking the user’s location. */ -- (MLNUserLocationAnnotationViewStyle *)mapViewStyleForDefaultUserLocationAnnotationView:(MLNMapView *)mapView NS_SWIFT_NAME(mapView(styleForDefaultUserLocationAnnotationView:)); +- (MLNUserLocationAnnotationViewStyle *)mapViewStyleForDefaultUserLocationAnnotationView: + (MLNMapView *)mapView NS_SWIFT_NAME(mapView(styleForDefaultUserLocationAnnotationView:)); /** Tells the delegate that the location of the user was updated. @@ -360,7 +373,8 @@ NS_ASSUME_NONNULL_BEGIN @param userLocation The location object representing the user’s latest location. This property may be `nil`. */ -- (void)mapView:(MLNMapView *)mapView didUpdateUserLocation:(nullable MLNUserLocation *)userLocation; +- (void)mapView:(MLNMapView *)mapView + didUpdateUserLocation:(nullable MLNUserLocation *)userLocation; /** Tells the delegate that an attempt to locate the user’s position failed. @@ -381,7 +395,9 @@ NS_ASSUME_NONNULL_BEGIN @param mode The new tracking mode. @param animated Whether the change caused an animated effect on the map. */ -- (void)mapView:(MLNMapView *)mapView didChangeUserTrackingMode:(MLNUserTrackingMode)mode animated:(BOOL)animated; +- (void)mapView:(MLNMapView *)mapView + didChangeUserTrackingMode:(MLNUserTrackingMode)mode + animated:(BOOL)animated; /** Returns a screen coordinate at which to position the user location annotation. @@ -400,15 +416,16 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the map's location updates accuracy authorization has changed. - + This method is called after the user changes location accuracy authorization when requesting location permissions or in privacy settings. - + @param mapView The map view that changed its location accuracy authorization. @param manager The location manager reporting the update. - + */ -- (void)mapView:(MLNMapView *)mapView didChangeLocationManagerAuthorization:(id)manager API_AVAILABLE(ios(14)); +- (void)mapView:(MLNMapView *)mapView + didChangeLocationManagerAuthorization:(id)manager API_AVAILABLE(ios(14)); // MARK: Managing the Appearance of Annotations @@ -438,7 +455,8 @@ NS_ASSUME_NONNULL_BEGIN image should be used for `MLNAnnotation` objects that have been added to your map */ -- (nullable MLNAnnotationImage *)mapView:(MLNMapView *)mapView imageForAnnotation:(id )annotation; +- (nullable MLNAnnotationImage *)mapView:(MLNMapView *)mapView + imageForAnnotation:(id)annotation; /** Returns the alpha value to use when rendering a shape annotation. @@ -541,7 +559,8 @@ NS_ASSUME_NONNULL_BEGIN `MLNViewAnnotation` to use for a given `MLNPointAnnotation` object on your map. */ -- (nullable MLNAnnotationView *)mapView:(MLNMapView *)mapView viewForAnnotation:(id )annotation; +- (nullable MLNAnnotationView *)mapView:(MLNMapView *)mapView + viewForAnnotation:(id)annotation; /** Tells the delegate that one or more annotation views have been added and @@ -554,7 +573,8 @@ NS_ASSUME_NONNULL_BEGIN @param annotationViews An array of `MLNAnnotationView` objects representing the views that were added. */ -- (void)mapView:(MLNMapView *)mapView didAddAnnotationViews:(NSArray *)annotationViews; +- (void)mapView:(MLNMapView *)mapView + didAddAnnotationViews:(NSArray *)annotationViews; // MARK: Selecting Annotations @@ -586,7 +606,7 @@ NS_ASSUME_NONNULL_BEGIN TODO: Dynamically style interactive points, learn how to remove an annotation view if it has already been selected. */ -- (void)mapView:(MLNMapView *)mapView didSelectAnnotation:(id )annotation; +- (void)mapView:(MLNMapView *)mapView didSelectAnnotation:(id)annotation; /** Tells the delegate that one of its annotations was deselected. @@ -600,7 +620,7 @@ NS_ASSUME_NONNULL_BEGIN @param mapView The map view containing the annotation. @param annotation The annotation that was deselected. */ -- (void)mapView:(MLNMapView *)mapView didDeselectAnnotation:(id )annotation; +- (void)mapView:(MLNMapView *)mapView didDeselectAnnotation:(id)annotation; /** Tells the delegate that one of its annotation views was selected. @@ -666,7 +686,7 @@ NS_ASSUME_NONNULL_BEGIN TODO: Default callout usage, learn how to show callouts for `MLNAnnotation` objects. */ -- (BOOL)mapView:(MLNMapView *)mapView annotationCanShowCallout:(id )annotation; +- (BOOL)mapView:(MLNMapView *)mapView annotationCanShowCallout:(id)annotation; /** Returns a callout view to display for the given annotation. @@ -687,7 +707,8 @@ NS_ASSUME_NONNULL_BEGIN TODO: Display custom views as callouts, learn how to customize an `MLNAnnotation` object's `MLNCalloutView`. */ -- (nullable id )mapView:(MLNMapView *)mapView calloutViewForAnnotation:(id )annotation; +- (nullable id)mapView:(MLNMapView *)mapView + calloutViewForAnnotation:(id)annotation; /** Returns the view to display on the left side of the standard callout bubble. @@ -717,7 +738,8 @@ NS_ASSUME_NONNULL_BEGIN TODO: Default callout usage, learn how to modify the view that is displayed on the left side of the standard callout bubble. */ -- (nullable UIView *)mapView:(MLNMapView *)mapView leftCalloutAccessoryViewForAnnotation:(id )annotation; +- (nullable UIView *)mapView:(MLNMapView *)mapView + leftCalloutAccessoryViewForAnnotation:(id)annotation; /** Returns the view to display on the right side of the standard callout bubble. @@ -747,7 +769,8 @@ NS_ASSUME_NONNULL_BEGIN TODO: Default callout usage, learn how to modify the view that is displayed on the right side of the standard callout bubble. */ -- (nullable UIView *)mapView:(MLNMapView *)mapView rightCalloutAccessoryViewForAnnotation:(id )annotation; +- (nullable UIView *)mapView:(MLNMapView *)mapView + rightCalloutAccessoryViewForAnnotation:(id)annotation; /** Tells the delegate that the user tapped one of the accessory controls in the @@ -776,7 +799,9 @@ NS_ASSUME_NONNULL_BEGIN TODO: Default callout usage, learn how to trigger an action when the standard callout bubble's accessory control is tapped. */ -- (void)mapView:(MLNMapView *)mapView annotation:(id )annotation calloutAccessoryControlTapped:(UIControl *)control; +- (void)mapView:(MLNMapView *)mapView + annotation:(id)annotation + calloutAccessoryControlTapped:(UIControl *)control; /** Tells the delegate that the user tapped on an annotation’s callout view. @@ -798,7 +823,7 @@ NS_ASSUME_NONNULL_BEGIN TODO: Display custom views as callouts, learn how to trigger an action when an `MLNAnnotation`s `MLNCalloutView` is tapped. */ -- (void)mapView:(MLNMapView *)mapView tapOnCalloutForAnnotation:(id )annotation; +- (void)mapView:(MLNMapView *)mapView tapOnCalloutForAnnotation:(id)annotation; @end diff --git a/platform/ios/src/MLNMapView_Private.h b/platform/ios/src/MLNMapView_Private.h index 17e93358b..6c7088d3c 100644 --- a/platform/ios/src/MLNMapView_Private.h +++ b/platform/ios/src/MLNMapView_Private.h @@ -1,13 +1,13 @@ +#import "MLNAnnotationContainerView.h" #import "MLNMapView.h" #import "MLNUserLocationAnnotationView.h" -#import "MLNAnnotationContainerView.h" #include namespace mbgl { - class Map; - class Renderer; -} +class Map; +class Renderer; +} // namespace mbgl class MLNMapViewImpl; @class MLNSource; @@ -48,7 +48,8 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const _Nonnull MLNUnderlyingMapUna - (void)didFailToLoadImage:(nonnull NSString *)imageName; - (BOOL)shouldRemoveStyleImage:(nonnull NSString *)imageName; -- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude zoomLevel:(double)zoomLevel; +- (CLLocationDistance)metersPerPointAtLatitude:(CLLocationDegrees)latitude + zoomLevel:(double)zoomLevel; /** Triggers another render pass even when it is not necessary. */ - (void)setNeedsRerender; @@ -59,14 +60,15 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const _Nonnull MLNUnderlyingMapUna - (mbgl::Map &)mbglMap; - (nonnull mbgl::Renderer *)renderer; -/** Returns whether the map view is currently loading or processing any assets required to render the map */ +/** Returns whether the map view is currently loading or processing any assets required to render + * the map */ - (BOOL)isFullyLoaded; /** Empties the in-memory tile cache. */ - (void)didReceiveMemoryWarning; /** Returns an instance of MLNMapView implementation. Used for integration testing. */ -- (nonnull MLNMapViewImpl *) viewImpl; +- (nonnull MLNMapViewImpl *)viewImpl; - (void)pauseRendering:(nonnull NSNotification *)notification; - (void)resumeRendering:(nonnull NSNotification *)notification; @@ -77,6 +79,6 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const _Nonnull MLNUnderlyingMapUna - (MLNMapCamera *_Nullable)cameraByTiltingToPitch:(CGFloat)pitch; -- (BOOL) _opaque; +- (BOOL)_opaque; @end diff --git a/platform/ios/src/MLNScaleBar.h b/platform/ios/src/MLNScaleBar.h index 9a1e9a62a..4a35d931d 100644 --- a/platform/ios/src/MLNScaleBar.h +++ b/platform/ios/src/MLNScaleBar.h @@ -1,5 +1,5 @@ -#import #import +#import @interface MLNScaleBar : UIView diff --git a/platform/ios/src/MLNUserLocation.h b/platform/ios/src/MLNUserLocation.h index 2a7ef704c..30737c135 100644 --- a/platform/ios/src/MLNUserLocation.h +++ b/platform/ios/src/MLNUserLocation.h @@ -1,8 +1,8 @@ -#import #import +#import -#import "MLNFoundation.h" #import "MLNAnnotation.h" +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN the user’s current location. You do not create instances of this class directly. Instead, you retrieve an existing `MLNUserLocation` object from the `userLocation` property of the map view displayed in your application. - + #### Related examples TODO: Customize the user location annotation,learn how to overide the default user location annotation. diff --git a/platform/ios/src/MLNUserLocationAnnotationView.h b/platform/ios/src/MLNUserLocationAnnotationView.h index d50fcbef2..8c553c14c 100644 --- a/platform/ios/src/MLNUserLocationAnnotationView.h +++ b/platform/ios/src/MLNUserLocationAnnotationView.h @@ -1,8 +1,8 @@ -#import #import +#import -#import "MLNFoundation.h" #import "MLNAnnotationView.h" +#import "MLNFoundation.h" NS_ASSUME_NONNULL_BEGIN @@ -25,7 +25,7 @@ MLN_EXPORT The value of this property is nil during initialization and while user tracking is inactive. - + #### Related examples TODO: Customize the user location annotation, learn how to customize the default user location annotation object. diff --git a/platform/ios/src/MLNUserLocationAnnotationView_Private.h b/platform/ios/src/MLNUserLocationAnnotationView_Private.h index 3a6601a7c..60af1ae7c 100644 --- a/platform/ios/src/MLNUserLocationAnnotationView_Private.h +++ b/platform/ios/src/MLNUserLocationAnnotationView_Private.h @@ -1,5 +1,5 @@ -#import "MLNUserLocationAnnotationView.h" #import "MLNUserLocation.h" +#import "MLNUserLocationAnnotationView.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/ios/src/MLNUserLocationHeadingArrowLayer.h b/platform/ios/src/MLNUserLocationHeadingArrowLayer.h index c61ca3a30..1f2b01b10 100644 --- a/platform/ios/src/MLNUserLocationHeadingArrowLayer.h +++ b/platform/ios/src/MLNUserLocationHeadingArrowLayer.h @@ -4,7 +4,8 @@ @interface MLNUserLocationHeadingArrowLayer : CAShapeLayer -- (instancetype)initWithUserLocationAnnotationView:(MLNUserLocationAnnotationView *)userLocationView; +- (instancetype)initWithUserLocationAnnotationView: + (MLNUserLocationAnnotationView *)userLocationView; - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy; - (void)updateTintColor:(CGColorRef)color; diff --git a/platform/ios/src/MLNUserLocationHeadingBeamLayer.h b/platform/ios/src/MLNUserLocationHeadingBeamLayer.h index 9cdff64c4..88baf698d 100644 --- a/platform/ios/src/MLNUserLocationHeadingBeamLayer.h +++ b/platform/ios/src/MLNUserLocationHeadingBeamLayer.h @@ -4,7 +4,8 @@ @interface MLNUserLocationHeadingBeamLayer : CALayer -- (MLNUserLocationHeadingBeamLayer *)initWithUserLocationAnnotationView:(MLNUserLocationAnnotationView *)userLocationView; +- (MLNUserLocationHeadingBeamLayer *)initWithUserLocationAnnotationView: + (MLNUserLocationAnnotationView *)userLocationView; - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy; - (void)updateTintColor:(CGColorRef)color; diff --git a/platform/ios/src/MLNUserLocationHeadingIndicator.h b/platform/ios/src/MLNUserLocationHeadingIndicator.h index 013bbd1e1..4d2b7b4be 100644 --- a/platform/ios/src/MLNUserLocationHeadingIndicator.h +++ b/platform/ios/src/MLNUserLocationHeadingIndicator.h @@ -3,7 +3,8 @@ @protocol MLNUserLocationHeadingIndicator -- (instancetype)initWithUserLocationAnnotationView:(MLNUserLocationAnnotationView *)userLocationView; +- (instancetype)initWithUserLocationAnnotationView: + (MLNUserLocationAnnotationView *)userLocationView; - (void)updateHeadingAccuracy:(CLLocationDirection)accuracy; - (void)updateTintColor:(CGColorRef)color; diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index a926ad438..ae1ee3057 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -7,7 +7,6 @@ FOUNDATION_EXPORT MLN_EXPORT double MapboxVersionNumber; /// Project version string for Mapbox. FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; -#import "MLNSettings.h" #import "MLNAnnotation.h" #import "MLNAnnotationImage.h" #import "MLNAnnotationView.h" @@ -22,6 +21,8 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "MLNCompassDirectionFormatter.h" #import "MLNComputedShapeSource.h" #import "MLNCoordinateFormatter.h" +#import "MLNCustomDrawableStyleLayer.h" +#import "MLNCustomStyleLayer.h" #import "MLNDistanceFormatter.h" #import "MLNFeature.h" #import "MLNFillExtrusionStyleLayer.h" @@ -38,15 +39,14 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "MLNMapCamera.h" #import "MLNMapProjection.h" #import "MLNMapSnapshotter.h" +#import "MLNMapView+IBAdditions.h" #import "MLNMapView.h" #import "MLNMapViewDelegate.h" -#import "MLNMapView+IBAdditions.h" #import "MLNMultiPoint.h" #import "MLNNetworkConfiguration.h" #import "MLNOfflinePack.h" #import "MLNOfflineRegion.h" #import "MLNOfflineStorage.h" -#import "MLNCustomStyleLayer.h" #import "MLNOverlay.h" #import "MLNPointAnnotation.h" #import "MLNPointCollection.h" @@ -55,6 +55,7 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "MLNRasterDEMSource.h" #import "MLNRasterStyleLayer.h" #import "MLNRasterTileSource.h" +#import "MLNSettings.h" #import "MLNShape.h" #import "MLNShapeCollection.h" #import "MLNShapeOfflineRegion.h" @@ -69,10 +70,9 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "MLNTypes.h" #import "MLNUserLocation.h" #import "MLNUserLocationAnnotationView.h" +#import "MLNUserLocationAnnotationViewStyle.h" #import "MLNVectorStyleLayer.h" #import "MLNVectorTileSource.h" #import "NSExpression+MLNAdditions.h" #import "NSPredicate+MLNAdditions.h" #import "NSValue+MLNAdditions.h" -#import "MLNUserLocationAnnotationViewStyle.h" -#import "MLNCustomDrawableStyleLayer.h" diff --git a/platform/ios/src/UIColor+MLNAdditions.h b/platform/ios/src/UIColor+MLNAdditions.h index 71d10e285..dda76d9dd 100644 --- a/platform/ios/src/UIColor+MLNAdditions.h +++ b/platform/ios/src/UIColor+MLNAdditions.h @@ -1,7 +1,7 @@ #import -#include #include +#include @interface UIColor (MLNAdditions) diff --git a/platform/ios/src/UIImage+MLNAdditions.h b/platform/ios/src/UIImage+MLNAdditions.h index e0680e765..0cfc60a0e 100644 --- a/platform/ios/src/UIImage+MLNAdditions.h +++ b/platform/ios/src/UIImage+MLNAdditions.h @@ -12,7 +12,8 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNResourceNotFoundException - (nullable instancetype)initWithMLNStyleImage:(const mbgl::style::Image &)styleImage; -- (nullable instancetype)initWithMLNPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage scale:(CGFloat)scale; +- (nullable instancetype)initWithMLNPremultipliedImage:(const mbgl::PremultipliedImage &&)mbglImage + scale:(CGFloat)scale; - (std::unique_ptr)mgl_styleImageWithIdentifier:(NSString *)identifier; @@ -20,7 +21,7 @@ FOUNDATION_EXTERN MLN_EXPORT MLNExceptionName const MLNResourceNotFoundException + (UIImage *)mgl_resourceImageNamed:(NSString *)imageName; -- (BOOL)isDataEqualTo:(UIImage*)otherImage; +- (BOOL)isDataEqualTo:(UIImage *)otherImage; @end diff --git a/platform/ios/test/MLNMockGestureRecognizers.h b/platform/ios/test/MLNMockGestureRecognizers.h index 29889e39f..ed2325aab 100644 --- a/platform/ios/test/MLNMockGestureRecognizers.h +++ b/platform/ios/test/MLNMockGestureRecognizers.h @@ -4,11 +4,11 @@ @interface UIPinchGestureRecognizerMock : UIPinchGestureRecognizer @property (nonatomic, readwrite) CGFloat velocity; @property (nonatomic) CGPoint locationInViewOverride; -@property(nonatomic, readwrite) UIGestureRecognizerState state; +@property (nonatomic, readwrite) UIGestureRecognizerState state; @end @interface UIRotationGestureRecognizerMock : UIRotationGestureRecognizer -@property(nonatomic, readwrite) UIGestureRecognizerState state; +@property (nonatomic, readwrite) UIGestureRecognizerState state; @end @interface UITapGestureRecognizerMock : UITapGestureRecognizer @@ -17,13 +17,13 @@ @end @interface UILongPressGestureRecognizerMock : UILongPressGestureRecognizer -@property(nonatomic, readwrite) UIGestureRecognizerState state; +@property (nonatomic, readwrite) UIGestureRecognizerState state; @property (assign) CGPoint mockTappedPoint; @end @interface UIPanGestureRecognizerMock : UIPanGestureRecognizer -@property(nonatomic, readwrite) UIGestureRecognizerState state; +@property (nonatomic, readwrite) UIGestureRecognizerState state; @property (assign) CGPoint firstFingerPoint; @property (assign) CGPoint secondFingerPoint; -@property(nonatomic, readwrite) NSUInteger numberOfTouches; +@property (nonatomic, readwrite) NSUInteger numberOfTouches; @end diff --git a/platform/ios/test/common/AppDelegate.h b/platform/ios/test/common/AppDelegate.h index 134c8063d..729f3fa25 100644 --- a/platform/ios/test/common/AppDelegate.h +++ b/platform/ios/test/common/AppDelegate.h @@ -1,4 +1,4 @@ -#import // UIApplicationDelegate +#import // UIApplicationDelegate @interface AppDelegate : UIResponder diff --git a/platform/ios/test/core/iosTestRunner.h b/platform/ios/test/core/iosTestRunner.h index 80ca625ff..c715d112c 100644 --- a/platform/ios/test/core/iosTestRunner.h +++ b/platform/ios/test/core/iosTestRunner.h @@ -2,10 +2,10 @@ #import -__attribute__((visibility ("default"))) +__attribute__((visibility("default"))) @interface IosTestRunner : NSObject -- (NSString*) getResultPath; -- (BOOL) getTestStatus; +- (NSString*)getResultPath; +- (BOOL)getTestStatus; @end diff --git a/platform/ios/test/core/ios_test_runner.cpp b/platform/ios/test/core/ios_test_runner.cpp index c5a5ff046..5dab40a0a 100644 --- a/platform/ios/test/core/ios_test_runner.cpp +++ b/platform/ios/test/core/ios_test_runner.cpp @@ -1,10 +1,8 @@ -#include - -#include - -#include - #include + +#include +#include +#include #include #define EXPORT __attribute__((visibility("default"))) diff --git a/platform/macos/app/AppDelegate.h b/platform/macos/app/AppDelegate.h index e962282f3..0dc25dd22 100644 --- a/platform/macos/app/AppDelegate.h +++ b/platform/macos/app/AppDelegate.h @@ -1,6 +1,6 @@ #import -extern NSString * const MLNApiKeyDefaultsKey; +extern NSString *const MLNApiKeyDefaultsKey; @interface AppDelegate : NSObject diff --git a/platform/macos/src/MLNAnnotationImage.h b/platform/macos/src/MLNAnnotationImage.h index 5159eabfe..9ebf260fb 100644 --- a/platform/macos/src/MLNAnnotationImage.h +++ b/platform/macos/src/MLNAnnotationImage.h @@ -24,7 +24,8 @@ MLN_EXPORT @return The initialized annotation image object or `nil` if there was a problem initializing the object. */ -+ (instancetype)annotationImageWithImage:(NSImage *)image reuseIdentifier:(NSString *)reuseIdentifier; ++ (instancetype)annotationImageWithImage:(NSImage *)image + reuseIdentifier:(NSString *)reuseIdentifier; // MARK: Getting and Setting Attributes diff --git a/platform/macos/src/MLNMapView+Impl.h b/platform/macos/src/MLNMapView+Impl.h index f74ed884e..bb66a2966 100644 --- a/platform/macos/src/MLNMapView+Impl.h +++ b/platform/macos/src/MLNMapView+Impl.h @@ -7,41 +7,39 @@ typedef struct _CGLContextObject* CGLContextObj; class MLNMapViewImpl : public mbgl::MapObserver { -public: - static std::unique_ptr Create(MLNMapView*); + public: + static std::unique_ptr Create(MLNMapView*); - MLNMapViewImpl(MLNMapView*); - virtual ~MLNMapViewImpl() = default; + MLNMapViewImpl(MLNMapView*); + virtual ~MLNMapViewImpl() = default; - virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0; + virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0; - // We need a static image of what was rendered for printing. - virtual mbgl::PremultipliedImage readStillImage() = 0; + // We need a static image of what was rendered for printing. + virtual mbgl::PremultipliedImage readStillImage() = 0; - virtual CGLContextObj getCGLContextObj() { - return nullptr; - } + virtual CGLContextObj getCGLContextObj() { return nullptr; } - // Called by the view delegate when it's time to render. - void render(); + // Called by the view delegate when it's time to render. + void render(); - // mbgl::MapObserver implementation - void onCameraWillChange(mbgl::MapObserver::CameraChangeMode) override; - void onCameraIsChanging() override; - void onCameraDidChange(mbgl::MapObserver::CameraChangeMode) override; - void onWillStartLoadingMap() override; - void onDidFinishLoadingMap() override; - void onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) override; - void onWillStartRenderingFrame() override; - void onDidFinishRenderingFrame(mbgl::MapObserver::RenderFrameStatus) override; - void onWillStartRenderingMap() override; - void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode) override; - void onDidFinishLoadingStyle() override; - void onSourceChanged(mbgl::style::Source& source) override; - void onDidBecomeIdle() override; - bool onCanRemoveUnusedStyleImage(const std::string& imageIdentifier) override; + // mbgl::MapObserver implementation + void onCameraWillChange(mbgl::MapObserver::CameraChangeMode) override; + void onCameraIsChanging() override; + void onCameraDidChange(mbgl::MapObserver::CameraChangeMode) override; + void onWillStartLoadingMap() override; + void onDidFinishLoadingMap() override; + void onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) override; + void onWillStartRenderingFrame() override; + void onDidFinishRenderingFrame(mbgl::MapObserver::RenderFrameStatus) override; + void onWillStartRenderingMap() override; + void onDidFinishRenderingMap(mbgl::MapObserver::RenderMode) override; + void onDidFinishLoadingStyle() override; + void onSourceChanged(mbgl::style::Source& source) override; + void onDidBecomeIdle() override; + bool onCanRemoveUnusedStyleImage(const std::string& imageIdentifier) override; -protected: - /// Cocoa map view that this adapter bridges to. - __weak MLNMapView *mapView = nullptr; + protected: + /// Cocoa map view that this adapter bridges to. + __weak MLNMapView* mapView = nullptr; }; diff --git a/platform/macos/src/MLNMapView+Metal.h b/platform/macos/src/MLNMapView+Metal.h index 7a361aae2..f6d12e66c 100644 --- a/platform/macos/src/MLNMapView+Metal.h +++ b/platform/macos/src/MLNMapView+Metal.h @@ -8,39 +8,35 @@ /// Adapter responsible for bridging calls from mbgl to MLNMapView and Cocoa. class MLNMapViewMetalImpl final : public MLNMapViewImpl, - public mbgl::mtl::RendererBackend, - public mbgl::gfx::Renderable { -public: - MLNMapViewMetalImpl(MLNMapView*); - ~MLNMapViewMetalImpl() override; + public mbgl::mtl::RendererBackend, + public mbgl::gfx::Renderable { + public: + MLNMapViewMetalImpl(MLNMapView*); + ~MLNMapViewMetalImpl() override; -public: - void restoreFramebufferBinding(); + public: + void restoreFramebufferBinding(); - // Implementation of mbgl::gfx::RendererBackend -public: - mbgl::gfx::Renderable& getDefaultRenderable() override { - return *this; - } + // Implementation of mbgl::gfx::RendererBackend + public: + mbgl::gfx::Renderable& getDefaultRenderable() override { return *this; } -private: - void activate() override; - void deactivate() override; - // End implementation of mbgl::gfx::RendererBackend + private: + void activate() override; + void deactivate() override; + // End implementation of mbgl::gfx::RendererBackend - // Implementation of mbgl::gl::RendererBackend -public: - void updateAssumedState() override; - // End implementation of mbgl::gl::Rendererbackend + // Implementation of mbgl::gl::RendererBackend + public: + void updateAssumedState() override; + // End implementation of mbgl::gl::Rendererbackend - // Implementation of MLNMapViewImpl -public: - mbgl::gfx::RendererBackend& getRendererBackend() override { - return *this; - } + // Implementation of MLNMapViewImpl + public: + mbgl::gfx::RendererBackend& getRendererBackend() override { return *this; } - mbgl::PremultipliedImage readStillImage() override; + mbgl::PremultipliedImage readStillImage() override; -private: - bool presentsWithTransaction = false; + private: + bool presentsWithTransaction = false; }; diff --git a/platform/macos/src/MLNMapView.h b/platform/macos/src/MLNMapView.h index 2762b3e26..f7f38e646 100644 --- a/platform/macos/src/MLNMapView.h +++ b/platform/macos/src/MLNMapView.h @@ -3,9 +3,9 @@ #import #import "MLNFoundation.h" -#import "MLNTypes.h" #import "MLNGeometry.h" #import "MLNStyle.h" +#import "MLNTypes.h" NS_ASSUME_NONNULL_BEGIN @@ -50,9 +50,9 @@ NS_ASSUME_NONNULL_BEGIN Adding your own gesture recognizer to `MLNMapView` will block the corresponding gesture recognizer built into `MLNMapView`. To avoid conflicts, define which gesture recognizer takes precedence. For example, you can subclass - `NSClickGestureRecognizer` and override `-[NSGestureRecognizer shouldRequireFailureOfGestureRecognizer:]`, - so that your subclass will be invoked only if the default `MLNMapView` click - gesture recognizer fails: + `NSClickGestureRecognizer` and override `-[NSGestureRecognizer + shouldRequireFailureOfGestureRecognizer:]`, so that your subclass will be invoked only if the + default `MLNMapView` click gesture recognizer fails: ```swift class MapClickGestureRecognizer: NSClickGestureRecognizer { @@ -65,8 +65,7 @@ NS_ASSUME_NONNULL_BEGIN @note You are responsible for getting permission to use the map data and for ensuring that your use adheres to the relevant terms of use. */ -MLN_EXPORT IB_DESIGNABLE -@interface MLNMapView : NSView +MLN_EXPORT IB_DESIGNABLE @interface MLNMapView : NSView // MARK: Creating Instances @@ -101,7 +100,7 @@ MLN_EXPORT IB_DESIGNABLE annotations displayed on the map, such as the styles to apply to individual annotations. */ -@property (nonatomic, weak, nullable) IBOutlet id delegate; +@property (nonatomic, weak, nullable) IBOutlet id delegate; // MARK: Configuring the Map’s Appearance @@ -189,17 +188,16 @@ MLN_EXPORT IB_DESIGNABLE /** A Boolean value indicating whether the map should prefetch tiles. - + When this property is set to `YES`, the map view prefetches tiles designed for a low zoom level and displays them until receiving more detailed tiles for the current zoom level. The prefetched tiles typically contain simplified versions of each shape, improving the map view’s perceived performance. - + The default value of this property is `YES`. */ @property (nonatomic, assign) BOOL prefetchesTiles; - // MARK: Manipulating the Viewpoint /** @@ -356,26 +354,32 @@ MLN_EXPORT IB_DESIGNABLE is `0`, this parameter is ignored. @param completion The block to execute after the animation finishes. */ -- (void)setCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion; +- (void)setCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + animationTimingFunction:(nullable CAMediaTimingFunction *)function + completionHandler:(nullable void (^)(void))completion; - /** - Moves the viewpoint to a different location with respect to the map with an - optional transition duration and timing function, and optionally some additional - padding on each side. - - @param camera The new viewpoint. - @param duration The amount of time, measured in seconds, that the transition - animation should take. Specify `0` to jump to the new viewpoint - instantaneously. - @param function A timing function used for the animation. Set this parameter to - `nil` for a transition that matches most system animations. If the duration - is `0`, this parameter is ignored. - @param edgePadding The minimum padding (in screen points) that would be visible - around the returned camera object if it were set as the receiver’s camera. - @param completion The block to execute after the animation finishes. - */ -- (void)setCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function edgePadding:(NSEdgeInsets)edgePadding completionHandler:(nullable void (^)(void))completion; +/** +Moves the viewpoint to a different location with respect to the map with an +optional transition duration and timing function, and optionally some additional +padding on each side. +@param camera The new viewpoint. +@param duration The amount of time, measured in seconds, that the transition +animation should take. Specify `0` to jump to the new viewpoint +instantaneously. +@param function A timing function used for the animation. Set this parameter to +`nil` for a transition that matches most system animations. If the duration +is `0`, this parameter is ignored. +@param edgePadding The minimum padding (in screen points) that would be visible +around the returned camera object if it were set as the receiver’s camera. + @param completion The block to execute after the animation finishes. +*/ +- (void)setCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + animationTimingFunction:(nullable CAMediaTimingFunction *)function + edgePadding:(NSEdgeInsets)edgePadding + completionHandler:(nullable void (^)(void))completion; /** Moves the viewpoint to a different location using a transition animation that @@ -404,7 +408,9 @@ MLN_EXPORT IB_DESIGNABLE is based on the length of the flight path. @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion; +- (void)flyToCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + completionHandler:(nullable void (^)(void))completion; /** Moves the viewpoint to a different location using a transition animation that @@ -424,7 +430,10 @@ MLN_EXPORT IB_DESIGNABLE `-setCamera:animated:` would have a midpoint at a higher altitude. @param completion The block to execute after the animation finishes. */ -- (void)flyToCamera:(MLNMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion; +- (void)flyToCamera:(MLNMapCamera *)camera + withDuration:(NSTimeInterval)duration + peakAltitude:(CLLocationDistance)peakAltitude + completionHandler:(nullable void (^)(void))completion; /** The geographic coordinate bounds visible in the receiver’s viewport. @@ -432,7 +441,7 @@ MLN_EXPORT IB_DESIGNABLE Changing the value of this property updates the receiver immediately. If you want to animate the change, use the `-setVisibleCoordinateBounds:animated:` method instead. - + If a longitude is less than −180 degrees or greater than 180 degrees, the visible bounds straddles the antimeridian or international date line. For example, if both Tokyo and San Francisco are visible, the visible bounds might @@ -443,7 +452,7 @@ MLN_EXPORT IB_DESIGNABLE /** Changes the receiver’s viewport to fit the given coordinate bounds, optionally animating the change. - + To bring both sides of the antimeridian or international date line into view, specify some longitudes less than −180 degrees or greater than 180 degrees. For example, to show both Tokyo and San Francisco simultaneously, you could set the @@ -463,7 +472,7 @@ MLN_EXPORT IB_DESIGNABLE specify some longitudes less than −180 degrees or greater than 180 degrees. For example, to show both Tokyo and San Francisco simultaneously, you could set the visible bounds to extend from (35.68476, −220.24257) to (37.78428, −122.41310). - + To specify a completion handler to execute after the animation finishes, use the `-setVisibleCoordinateBounds:edgePadding:animated:completionHandler:` method. @@ -473,7 +482,9 @@ MLN_EXPORT IB_DESIGNABLE @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. */ -- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(NSEdgeInsets)insets animated:(BOOL)animated; +- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(NSEdgeInsets)insets + animated:(BOOL)animated; /** Changes the receiver’s viewport to fit the given coordinate bounds with some @@ -491,7 +502,10 @@ MLN_EXPORT IB_DESIGNABLE zooming or `NO` to immediately display the given bounds. @param completion The block executed after the animation finishes. */ -- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(NSEdgeInsets)insets animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setVisibleCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(NSEdgeInsets)insets + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** Sets the visible region so that the map displays the specified annotations. @@ -505,7 +519,7 @@ MLN_EXPORT IB_DESIGNABLE @param animated `YES` if you want the map region change to be animated, or `NO` if you want the map to display the new region immediately without animations. */ -- (void)showAnnotations:(NSArray> *)annotations animated:(BOOL)animated; +- (void)showAnnotations:(NSArray> *)annotations animated:(BOOL)animated; /** Sets the visible region so that the map displays the specified annotations with @@ -513,7 +527,7 @@ MLN_EXPORT IB_DESIGNABLE Calling this method updates the value in the `visibleCoordinateBounds` property and potentially other properties to reflect the new map region. - + To specify a completion handler to execute after the animation finishes, use the `-showAnnotations:edgePadding:animated:completionHandler:` method. @@ -523,7 +537,9 @@ MLN_EXPORT IB_DESIGNABLE @param animated `YES` if you want the map region change to be animated, or `NO` if you want the map to display the new region immediately without animations. */ -- (void)showAnnotations:(NSArray> *)annotations edgePadding:(NSEdgeInsets)insets animated:(BOOL)animated; +- (void)showAnnotations:(NSArray> *)annotations + edgePadding:(NSEdgeInsets)insets + animated:(BOOL)animated; /** Sets the visible region so that the map displays the specified annotations with @@ -540,7 +556,10 @@ MLN_EXPORT IB_DESIGNABLE if you want the map to display the new region immediately without animations. @param completion The block executed after the animation finishes. */ -- (void)showAnnotations:(NSArray> *)annotations edgePadding:(NSEdgeInsets)insets animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)showAnnotations:(NSArray> *)annotations + edgePadding:(NSEdgeInsets)insets + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; /** Returns the camera that best fits the given coordinate bounds. @@ -565,13 +584,14 @@ MLN_EXPORT IB_DESIGNABLE including the entire coordinate bounds. The camera object uses the current direction and pitch. */ -- (MLNMapCamera *)cameraThatFitsCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(NSEdgeInsets)insets; +- (MLNMapCamera *)cameraThatFitsCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(NSEdgeInsets)insets; /** Returns the camera that best fits the given coordinate bounds with some additional padding on each side, matching an existing camera as much as possible. - + @param camera The camera that the return camera should adhere to. All values on this camera will be manipulated except for pitch and direction. @param bounds The coordinate bounds to fit to the receiver’s viewport. @@ -582,12 +602,14 @@ MLN_EXPORT IB_DESIGNABLE including the entire coordinate bounds. The initial camera's pitch and direction will be honored. */ -- (MLNMapCamera *)camera:(MLNMapCamera *)camera fittingCoordinateBounds:(MLNCoordinateBounds)bounds edgePadding:(NSEdgeInsets)insets; +- (MLNMapCamera *)camera:(MLNMapCamera *)camera + fittingCoordinateBounds:(MLNCoordinateBounds)bounds + edgePadding:(NSEdgeInsets)insets; /** Returns the camera that best fits the given shape with some additional padding on each side, matching an existing camera as much as possible. - + @param camera The camera that the return camera should adhere to. All values on this camera will be manipulated except for pitch and direction. @param shape The shape to fit to the receiver’s viewport. @@ -597,7 +619,9 @@ MLN_EXPORT IB_DESIGNABLE (close to the ground) as possible while still including the entire shape. The initial camera's pitch and direction will be honored. */ -- (MLNMapCamera *)camera:(MLNMapCamera *)camera fittingShape:(MLNShape *)shape edgePadding:(NSEdgeInsets)insets; +- (MLNMapCamera *)camera:(MLNMapCamera *)camera + fittingShape:(MLNShape *)shape + edgePadding:(NSEdgeInsets)insets; /** Returns the camera that best fits the given shape with some additional padding @@ -612,7 +636,9 @@ MLN_EXPORT IB_DESIGNABLE (close to the ground) as possible while still including the entire shape. The camera object uses the current pitch. */ -- (MLNMapCamera *)cameraThatFitsShape:(MLNShape *)shape direction:(CLLocationDirection)direction edgePadding:(NSEdgeInsets)insets; +- (MLNMapCamera *)cameraThatFitsShape:(MLNShape *)shape + direction:(CLLocationDirection)direction + edgePadding:(NSEdgeInsets)insets; /** A Boolean value indicating whether the receiver automatically adjusts its @@ -659,7 +685,7 @@ MLN_EXPORT IB_DESIGNABLE When the value of the `automaticallyAdjustsContentInsets` property is `YES`, the value of this property may be overridden at any time. - + To specify a completion handler to execute after the animation finishes, use the `-setContentInsets:animated:completionHandler:` method. @@ -668,13 +694,15 @@ MLN_EXPORT IB_DESIGNABLE the content insets or `NO` if you want the map to inset the content immediately. */ -- (void)setContentInsets:(NSEdgeInsets)contentInsets animated:(BOOL)animated __attribute__((deprecated("Use `-setContentInsets:animated:completionHandler:` instead."))); +- (void)setContentInsets:(NSEdgeInsets)contentInsets + animated:(BOOL)animated + __attribute__((deprecated("Use `-setContentInsets:animated:completionHandler:` instead."))); /** Sets the distance from the edges of the map view’s frame to the edges of the map view’s logical viewport with an optional transition animation and completion handler. - + When the value of this property is equal to `NSEdgeInsetsZero`, viewport properties such as `centerCoordinate` assume a viewport that matches the map view’s frame. Otherwise, those properties are inset, excluding part of the @@ -683,14 +711,16 @@ MLN_EXPORT IB_DESIGNABLE When the value of the `automaticallyAdjustsContentInsets` property is `YES`, the value of this property may be overridden at any time. - + @param contentInsets The new values to inset the content by. @param animated Specify `YES` if you want the map view to animate the change to the content insets or `NO` if you want the map to inset the content immediately. @param completion The block executed after the animation finishes. */ -- (void)setContentInsets:(NSEdgeInsets)contentInsets animated:(BOOL)animated completionHandler:(nullable void (^)(void))completion; +- (void)setContentInsets:(NSEdgeInsets)contentInsets + animated:(BOOL)animated + completionHandler:(nullable void (^)(void))completion; // MARK: Configuring How the User Interacts with the Map @@ -761,7 +791,7 @@ MLN_EXPORT IB_DESIGNABLE annotations are associated with the map view, the value of this property is `nil`. */ -@property (nonatomic, readonly, nullable) NSArray> *annotations; +@property (nonatomic, readonly, nullable) NSArray> *annotations; /** Adds an annotation to the map view. @@ -776,7 +806,7 @@ MLN_EXPORT IB_DESIGNABLE must conform to the `MLNAnnotation` protocol. The map view retains the annotation object. */ -- (void)addAnnotation:(id )annotation; +- (void)addAnnotation:(id)annotation; /** Adds an array of annotations to the map view. @@ -791,7 +821,7 @@ MLN_EXPORT IB_DESIGNABLE must conform to the `MLNAnnotation` protocol. The map view retains each individual annotation object. */ -- (void)addAnnotations:(NSArray> *)annotations; +- (void)addAnnotations:(NSArray> *)annotations; /** The complete list of annotations associated with the receiver that are @@ -801,7 +831,7 @@ MLN_EXPORT IB_DESIGNABLE annotations are associated with the map view or if no annotations associated with the map view are currently visible, the value of this property is `nil`. */ -@property (nonatomic, readonly, nullable) NSArray> *visibleAnnotations; +@property (nonatomic, readonly, nullable) NSArray> *visibleAnnotations; /** Removes an annotation from the map view, deselecting it if it is selected. @@ -813,7 +843,7 @@ MLN_EXPORT IB_DESIGNABLE @param annotation The annotation object to remove. This object must conform to the `MLNAnnotation` protocol. */ -- (void)removeAnnotation:(id )annotation; +- (void)removeAnnotation:(id)annotation; /** Removes an array of annotations from the map view, deselecting any selected @@ -826,7 +856,7 @@ MLN_EXPORT IB_DESIGNABLE @param annotations The array of annotation objects to remove. Objects in the array must conform to the `MLNAnnotation` protocol. */ -- (void)removeAnnotations:(NSArray> *)annotations; +- (void)removeAnnotations:(NSArray> *)annotations; /** Returns a reusable annotation image object associated with its identifier. @@ -841,7 +871,8 @@ MLN_EXPORT IB_DESIGNABLE @return An annotation image object with the given identifier, or `nil` if no such object exists in the reuse queue. */ -- (nullable MLNAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier:(NSString *)identifier; +- (nullable MLNAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier: + (NSString *)identifier; /** Returns the list of annotations associated with the receiver that intersect with @@ -852,7 +883,7 @@ MLN_EXPORT IB_DESIGNABLE no annotations associated with the map view are currently visible in the rectangle. */ -- (nullable NSArray> *)visibleAnnotationsInRect:(CGRect)rect; +- (nullable NSArray> *)visibleAnnotationsInRect:(CGRect)rect; // MARK: Managing Annotation Selections @@ -869,7 +900,7 @@ MLN_EXPORT IB_DESIGNABLE @note In versions prior to `4.0.0` if the annotation was offscreen it was not selected. */ -@property (nonatomic, copy) NSArray> *selectedAnnotations; +@property (nonatomic, copy) NSArray> *selectedAnnotations; /** Selects an annotation and displays a callout popover for it. @@ -880,14 +911,14 @@ MLN_EXPORT IB_DESIGNABLE @param annotation The annotation object to select. */ -- (void)selectAnnotation:(id )annotation; +- (void)selectAnnotation:(id)annotation; /** Deselects an annotation and hides its callout popover. @param annotation The annotation object to deselect. */ -- (void)deselectAnnotation:(nullable id )annotation; +- (void)deselectAnnotation:(nullable id)annotation; /** A common view controller for managing a callout popover’s content view. @@ -917,7 +948,7 @@ MLN_EXPORT IB_DESIGNABLE multiple point annotations coincide with the point, the return value is the annotation that would be selected if the user clicks at this point. */ -- (id )annotationAtPoint:(NSPoint)point; +- (id)annotationAtPoint:(NSPoint)point; // MARK: Overlaying the Map @@ -928,7 +959,7 @@ MLN_EXPORT IB_DESIGNABLE overlays are associated with the map view, the value of this property is empty array. */ -@property (nonatomic, readonly, nonnull) NSArray> *overlays; +@property (nonatomic, readonly, nonnull) NSArray> *overlays; /** Adds a single overlay to the map. @@ -938,7 +969,7 @@ MLN_EXPORT IB_DESIGNABLE @param overlay The overlay object to add. This object must conform to the `MLNOverlay` protocol. */ -- (void)addOverlay:(id )overlay; +- (void)addOverlay:(id)overlay; /** Adds an array of overlays to the map. @@ -948,7 +979,7 @@ MLN_EXPORT IB_DESIGNABLE @param overlays An array of objects, each of which must conform to the `MLNOverlay` protocol. */ -- (void)addOverlays:(NSArray> *)overlays; +- (void)addOverlays:(NSArray> *)overlays; /** Removes a single overlay from the map. @@ -958,7 +989,7 @@ MLN_EXPORT IB_DESIGNABLE @param overlay The overlay object to remove. */ -- (void)removeOverlay:(id )overlay; +- (void)removeOverlay:(id)overlay; /** Removes an array of overlays from the map. @@ -968,7 +999,7 @@ MLN_EXPORT IB_DESIGNABLE @param overlays An array of objects, each of which conforms to the `MLNOverlay` protocol. */ -- (void)removeOverlays:(NSArray> *)overlays; +- (void)removeOverlays:(NSArray> *)overlays; // MARK: Accessing the Underlying Map Data @@ -984,7 +1015,8 @@ MLN_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesAtPoint:(NSPoint)point NS_SWIFT_NAME(visibleFeatures(at:)); +- (NSArray> *)visibleFeaturesAtPoint:(NSPoint)point + NS_SWIFT_NAME(visibleFeatures(at:)); /** Returns an array of rendered map features that intersect with a given point, @@ -1003,12 +1035,15 @@ MLN_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesAtPoint:(NSPoint)point inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:)); +- (NSArray> *)visibleFeaturesAtPoint:(NSPoint)point + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:)); /** Returns an array of rendered map features that intersect with a given point, restricted to the given style layers and filtered by the given predicate. - + Each object in the returned array represents a feature rendered by the current style and provides access to attributes specified by the relevant map content sources. The returned array includes features loaded by @@ -1043,7 +1078,7 @@ MLN_EXPORT IB_DESIGNABLE To find out the layer names in a particular style, view the style in Mapbox Studio. - + Only visible features are returned. To obtain features regardless of visibility, use the `-[MLNVectorTileSource featuresInSourceLayersWithIdentifiers:predicate:]` and @@ -1056,7 +1091,7 @@ MLN_EXPORT IB_DESIGNABLE inspectable in Interface Builder, or a manually constructed `NSURL`. This approach also avoids layer identifer name changes that will occur in the default style’s layers over time. - + @param point A point expressed in the map view’s coordinate system. @param styleLayerIdentifiers A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these @@ -1065,7 +1100,11 @@ MLN_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesAtPoint:(NSPoint)point inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:predicate:)); +- (NSArray> *)visibleFeaturesAtPoint:(NSPoint)point + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + predicate:(nullable NSPredicate *)predicate + NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:predicate:)); /** Returns an array of rendered map features that intersect with the given @@ -1080,12 +1119,12 @@ MLN_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesInRect:(NSRect)rect NS_SWIFT_NAME(visibleFeatures(in:)); +- (NSArray> *)visibleFeaturesInRect:(NSRect)rect NS_SWIFT_NAME(visibleFeatures(in:)); /** Returns an array of rendered map features that intersect with the given rectangle, restricted to the given style layers. - + This method returns all the intersecting features from the specified layers. To filter the returned features, use the `-visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:predicate:` method. For @@ -1099,13 +1138,16 @@ MLN_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesInRect:(NSRect)rect inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:)); +- (NSArray> *)visibleFeaturesInRect:(NSRect)rect + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + NS_SWIFT_NAME(visibleFeatures(at:styleLayerIdentifiers:)); /** Returns an array of rendered map features that intersect with the given rectangle, restricted to the given style layers and filtered by the given predicate. - + Each object in the returned array represents a feature rendered by the current style and provides access to attributes specified by the relevant map content sources. The returned array includes features loaded by @@ -1141,7 +1183,7 @@ MLN_EXPORT IB_DESIGNABLE To find out the layer names in a particular style, view the style in Mapbox Studio. - + Only visible features are returned. To obtain features regardless of visibility, use the `-[MLNVectorTileSource featuresInSourceLayersWithIdentifiers:predicate:]` and @@ -1154,7 +1196,7 @@ MLN_EXPORT IB_DESIGNABLE inspectable in Interface Builder, or a manually constructed `NSURL`. This approach also avoids layer identifer name changes that will occur in the default style’s layers over time. - + @param rect A rectangle expressed in the map view’s coordinate system. @param styleLayerIdentifiers A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these @@ -1163,7 +1205,11 @@ MLN_EXPORT IB_DESIGNABLE @return An array of objects conforming to the `MLNFeature` protocol that represent features in the sources used by the current style. */ -- (NSArray> *)visibleFeaturesInRect:(NSRect)rect inStyleLayersWithIdentifiers:(nullable NSSet *)styleLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:predicate:)); +- (NSArray> *)visibleFeaturesInRect:(NSRect)rect + inStyleLayersWithIdentifiers: + (nullable NSSet *)styleLayerIdentifiers + predicate:(nullable NSPredicate *)predicate + NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:predicate:)); // MARK: Converting Geographic Coordinates @@ -1179,7 +1225,8 @@ MLN_EXPORT IB_DESIGNABLE @return The point (in the appropriate view or window coordinate system) corresponding to the given geographic coordinate. */ -- (NSPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable NSView *)view; +- (NSPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate + toPointToView:(nullable NSView *)view; /** Converts a point in the given view’s coordinate system to a geographic @@ -1194,7 +1241,7 @@ MLN_EXPORT IB_DESIGNABLE /** Converts a geographic bounding box to a rectangle in the given view’s coordinate system. - + To bring both sides of the antimeridian or international date line into view, specify some longitudes less than −180 degrees or greater than 180 degrees. For example, to show both Tokyo and San Francisco simultaneously, you could set the @@ -1211,7 +1258,7 @@ MLN_EXPORT IB_DESIGNABLE /** Converts a rectangle in the given view’s coordinate system to a geographic bounding box. - + If a longitude is less than −180 degrees or greater than 180 degrees, the bounding box straddles the antimeridian or international date line. diff --git a/platform/macos/src/MLNMapViewDelegate.h b/platform/macos/src/MLNMapViewDelegate.h index e0ddac330..92dedd8cf 100644 --- a/platform/macos/src/MLNMapViewDelegate.h +++ b/platform/macos/src/MLNMapViewDelegate.h @@ -46,9 +46,9 @@ NS_ASSUME_NONNULL_BEGIN an animation, whether due to a user gesture or due to a call to a method such as `-[MLNMapView setCamera:animated:]`. This method can be called before `-mapViewDidFinishLoadingMap:` is called. - - During the animation, this method may be called many times to report updates - to the viewpoint. Therefore, your implementation of this method should be as + + During the animation, this method may be called many times to report updates + to the viewpoint. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting performance. @param mapView The map view whose viewpoint is changing. @@ -61,9 +61,9 @@ NS_ASSUME_NONNULL_BEGIN This method is called whenever the currently displayed map camera has finished changing, after any calls to `-mapViewRegionIsChanging:` due to animation. - This method can be called before `-mapViewDidFinishLoadingMap:` is + This method can be called before `-mapViewDidFinishLoadingMap:` is called. - + @param mapView The map view whose viewpoint has changed. @param animated Whether the change caused an animated effect on the map. */ @@ -72,14 +72,14 @@ NS_ASSUME_NONNULL_BEGIN /** Asks the delegate whether the map view should be allowed to change from the existing camera to the new camera in response to a user gesture. - + This method is called as soon as the user gesture is recognized. It is not called in response to a programmatic camera change, such as by setting the `centerCoordinate` property or calling `-flyToCamera:completionHandler:`. - - This method is called many times during gesturing, so you should avoid performing + + This method is called many times during gesturing, so you should avoid performing complex or performance-intensive tasks in your implementation. - + @param mapView The map view that the user is manipulating. @param oldCamera The camera representing the viewpoint at the moment the gesture is recognized. If this method returns `NO`, the map view’s camera @@ -89,7 +89,9 @@ NS_ASSUME_NONNULL_BEGIN @return A Boolean value indicating whether the map view should stay at `oldCamera` or change to `newCamera`. */ -- (BOOL)mapView:(MLNMapView *)mapView shouldChangeFromCamera:(MLNMapCamera *)oldCamera toCamera:(MLNMapCamera *)newCamera; +- (BOOL)mapView:(MLNMapView *)mapView + shouldChangeFromCamera:(MLNMapCamera *)oldCamera + toCamera:(MLNMapCamera *)newCamera; // MARK: Loading the Map @@ -175,11 +177,11 @@ NS_ASSUME_NONNULL_BEGIN Tells the delegate that the map view is entering an idle state, and no more drawing will be necessary until new data is loaded or there is some interaction with the map. - + - No camera transitions are in progress - All currently requested tiles have loaded - All fade/transition animations have completed - + @param mapView The map view that has just entered the idle state. */ - (void)mapViewDidBecomeIdle:(MLNMapView *)mapView; @@ -202,7 +204,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)mapView:(MLNMapView *)mapView didFinishLoadingStyle:(MLNStyle *)style; /** - Tells the delegate that the `mapView` is missing an image. The image should be added synchronously with `-[MLNStyle setImage:forName:]` to be rendered on the current zoom level. When loading icons asynchronously, you can load a placeholder image and replace it when your image has loaded. + Tells the delegate that the `mapView` is missing an image. The image should be added synchronously + with `-[MLNStyle setImage:forName:]` to be rendered on the current zoom level. When loading icons + asynchronously, you can load a placeholder image and replace it when your image has loaded. @param mapView The map view that is loading the image. @param imageName The name of the image that is missing. @@ -211,11 +215,11 @@ NS_ASSUME_NONNULL_BEGIN /** Asks the delegate whether the map view should evict cached images. - + This method is called in two scenarios: when the cumulative size of unused images exceeds the cache size or when the last tile that includes the image is removed from memory. - + @param mapView The map view that is evicting the image. @param imageName The image name that is going to be removed. @return A Boolean value indicating whether the map view should evict @@ -235,7 +239,8 @@ NS_ASSUME_NONNULL_BEGIN @return The image object to display for the given annotation or `nil` if you want to display the default marker image. */ -- (nullable MLNAnnotationImage *)mapView:(MLNMapView *)mapView imageForAnnotation:(id )annotation; +- (nullable MLNAnnotationImage *)mapView:(MLNMapView *)mapView + imageForAnnotation:(id)annotation; /** Returns the alpha value to use when rendering a shape annotation. @@ -300,10 +305,10 @@ NS_ASSUME_NONNULL_BEGIN /** Returns a Boolean value indicating whether the shape annotation can be selected. - + If the return value is `YES`, the user can select the annotation by clicking on it. If the delegate does not implement this method, the default value is `YES`. - + @param mapView The map view that has selected the annotation. @param annotation The object representing the shape annotation. @return A Boolean value indicating whether the annotation can be selected. @@ -318,7 +323,7 @@ NS_ASSUME_NONNULL_BEGIN @param mapView The map view containing the annotation. @param annotation The annotation that was selected. */ -- (void)mapView:(MLNMapView *)mapView didSelectAnnotation:(id )annotation; +- (void)mapView:(MLNMapView *)mapView didSelectAnnotation:(id)annotation; /** Tells the delegate that one of its annotations has been deselected. @@ -328,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN @param mapView The map view containing the annotation. @param annotation The annotation that was deselected. */ -- (void)mapView:(MLNMapView *)mapView didDeselectAnnotation:(id )annotation; +- (void)mapView:(MLNMapView *)mapView didDeselectAnnotation:(id)annotation; // MARK: Managing Callout Popovers @@ -353,7 +358,7 @@ NS_ASSUME_NONNULL_BEGIN @return A Boolean value indicating whether the annotation should show a callout. */ -- (BOOL)mapView:(MLNMapView *)mapView annotationCanShowCallout:(id )annotation; +- (BOOL)mapView:(MLNMapView *)mapView annotationCanShowCallout:(id)annotation; /** Returns a view controller to manage the callout popover’s content view. @@ -371,7 +376,8 @@ NS_ASSUME_NONNULL_BEGIN @param annotation The object representing the annotation. @return A view controller for the given annotation. */ -- (nullable NSViewController *)mapView:(MLNMapView *)mapView calloutViewControllerForAnnotation:(id )annotation; +- (nullable NSViewController *)mapView:(MLNMapView *)mapView + calloutViewControllerForAnnotation:(id)annotation; @end diff --git a/platform/macos/src/MLNMapView_Private.h b/platform/macos/src/MLNMapView_Private.h index 490d42ef6..e496e84f3 100644 --- a/platform/macos/src/MLNMapView_Private.h +++ b/platform/macos/src/MLNMapView_Private.h @@ -3,9 +3,9 @@ #include namespace mbgl { - class Map; - class Renderer; -} +class Map; +class Renderer; +} // namespace mbgl @class MLNSource; diff --git a/platform/macos/src/Mapbox.h b/platform/macos/src/Mapbox.h index d8aeab391..f7a748fa0 100644 --- a/platform/macos/src/Mapbox.h +++ b/platform/macos/src/Mapbox.h @@ -8,22 +8,37 @@ FOUNDATION_EXPORT MLN_EXPORT double MapboxVersionNumber; /// Project version string for Mapbox. FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; -#import "MLNSettings.h" #import "MLNAnnotation.h" #import "MLNAnnotationImage.h" +#import "MLNAttributedExpression.h" +#import "MLNAttributionInfo.h" +#import "MLNBackgroundStyleLayer.h" +#import "MLNCircleStyleLayer.h" #import "MLNClockDirectionFormatter.h" #import "MLNCluster.h" #import "MLNCompassDirectionFormatter.h" +#import "MLNComputedShapeSource.h" #import "MLNCoordinateFormatter.h" +#import "MLNCustomStyleLayer.h" #import "MLNDistanceFormatter.h" #import "MLNFeature.h" +#import "MLNFillExtrusionStyleLayer.h" +#import "MLNFillStyleLayer.h" +#import "MLNForegroundStyleLayer.h" #import "MLNGeometry.h" +#import "MLNHeatmapStyleLayer.h" +#import "MLNHillshadeStyleLayer.h" +#import "MLNImageSource.h" #import "MLNLight.h" +#import "MLNLineStyleLayer.h" +#import "MLNLoggingConfiguration.h" #import "MLNMapCamera.h" -#import "MLNMapView.h" +#import "MLNMapSnapshotter.h" #import "MLNMapView+IBAdditions.h" +#import "MLNMapView.h" #import "MLNMapViewDelegate.h" #import "MLNMultiPoint.h" +#import "MLNNetworkConfiguration.h" #import "MLNOfflinePack.h" #import "MLNOfflineRegion.h" #import "MLNOfflineStorage.h" @@ -32,39 +47,24 @@ FOUNDATION_EXPORT MLN_EXPORT const unsigned char MapboxVersionString[]; #import "MLNPointCollection.h" #import "MLNPolygon.h" #import "MLNPolyline.h" +#import "MLNRasterDEMSource.h" +#import "MLNRasterStyleLayer.h" +#import "MLNRasterTileSource.h" +#import "MLNSettings.h" #import "MLNShape.h" #import "MLNShapeCollection.h" +#import "MLNShapeOfflineRegion.h" +#import "MLNShapeSource.h" +#import "MLNSource.h" #import "MLNStyle.h" #import "MLNStyleLayer.h" -#import "MLNForegroundStyleLayer.h" -#import "MLNVectorStyleLayer.h" -#import "MLNFillStyleLayer.h" -#import "MLNFillExtrusionStyleLayer.h" -#import "MLNLineStyleLayer.h" -#import "MLNSymbolStyleLayer.h" -#import "MLNRasterStyleLayer.h" -#import "MLNCircleStyleLayer.h" -#import "MLNBackgroundStyleLayer.h" -#import "MLNHeatmapStyleLayer.h" -#import "MLNHillshadeStyleLayer.h" -#import "MLNCustomStyleLayer.h" -#import "MLNSource.h" -#import "MLNTileSource.h" -#import "MLNVectorTileSource.h" -#import "MLNShapeSource.h" -#import "MLNComputedShapeSource.h" -#import "MLNRasterTileSource.h" -#import "MLNRasterDEMSource.h" -#import "MLNImageSource.h" -#import "MLNTilePyramidOfflineRegion.h" -#import "MLNShapeOfflineRegion.h" -#import "MLNTypes.h" -#import "NSValue+MLNAdditions.h" #import "MLNStyleValue.h" -#import "MLNAttributionInfo.h" -#import "MLNMapSnapshotter.h" +#import "MLNSymbolStyleLayer.h" +#import "MLNTilePyramidOfflineRegion.h" +#import "MLNTileSource.h" +#import "MLNTypes.h" +#import "MLNVectorStyleLayer.h" +#import "MLNVectorTileSource.h" #import "NSExpression+MLNAdditions.h" #import "NSPredicate+MLNAdditions.h" -#import "MLNLoggingConfiguration.h" -#import "MLNNetworkConfiguration.h" -#import "MLNAttributedExpression.h" +#import "NSValue+MLNAdditions.h" diff --git a/platform/macos/src/NSColor+MLNAdditions.h b/platform/macos/src/NSColor+MLNAdditions.h index f18771f13..63c3de3ec 100644 --- a/platform/macos/src/NSColor+MLNAdditions.h +++ b/platform/macos/src/NSColor+MLNAdditions.h @@ -1,7 +1,7 @@ #import -#include #include +#include @interface NSColor (MLNAdditions) diff --git a/platform/macos/src/NSImage+MLNAdditions.h b/platform/macos/src/NSImage+MLNAdditions.h index d1ff83e21..607b947a9 100644 --- a/platform/macos/src/NSImage+MLNAdditions.h +++ b/platform/macos/src/NSImage+MLNAdditions.h @@ -6,13 +6,13 @@ NS_ASSUME_NONNULL_BEGIN @interface NSImage (MLNAdditions) -- (nullable instancetype)initWithMLNPremultipliedImage:(mbgl::PremultipliedImage&&)image; +- (nullable instancetype)initWithMLNPremultipliedImage:(mbgl::PremultipliedImage &&)image; - (nullable instancetype)initWithMLNStyleImage:(const mbgl::style::Image &)image; - (std::unique_ptr)mgl_styleImageWithIdentifier:(NSString *)identifier; -- (mbgl::PremultipliedImage) mgl_premultipliedImage; +- (mbgl::PremultipliedImage)mgl_premultipliedImage; @end diff --git a/platform/scripts/check-public-symbols.js b/platform/scripts/check-public-symbols.js index f46b9fb7b..ac48729a0 100644 --- a/platform/scripts/check-public-symbols.js +++ b/platform/scripts/check-public-symbols.js @@ -30,13 +30,13 @@ function hasMissingSymbols(os) { _.forEach(structure['key.substructure'], function (substructure) { switch (substructure['key.kind']) { case 'sourcekitten.source.lang.objc.decl.class': - if (!(keyword.test(src[substructure['key.doc.line'] - 1]) || keyword.test(src[substructure['key.doc.line'] - 2]))) { + if (!keyword.test(src[substructure['key.doc.line'] - 1]) && !keyword.test(src[substructure['key.doc.line'] - 2]) && !keyword.test(src[substructure['key.doc.line'] - 3]) && !keyword.test(src[substructure['key.doc.line'] - 4])) { console.warn(`- missing symbol export for class ${substructure['key.name']} in ${path}:${substructure['key.doc.line']}:${substructure['key.doc.column']}`); missing = true; } break; case 'sourcekitten.source.lang.objc.decl.constant': - if (!keyword.test(src[substructure['key.doc.line'] - 1])) { + if (!keyword.test(src[substructure['key.doc.line'] - 1]) && !keyword.test(src[substructure['key.doc.line'] - 2])) { console.warn(`- missing symbol export for constant ${substructure['key.name']} in ${path}:${substructure['key.doc.line']}:${substructure['key.doc.column']}`); missing = true; } diff --git a/render-test/ios/iosTestRunner.h b/render-test/ios/iosTestRunner.h index 7dc2e24ef..967ea2620 100644 --- a/render-test/ios/iosTestRunner.h +++ b/render-test/ios/iosTestRunner.h @@ -1,11 +1,11 @@ #import -__attribute__((visibility ("default"))) +__attribute__((visibility("default"))) @interface IosTestRunner : NSObject -- (NSString*) getStyleResultPath; -- (NSString*) getMetricResultPath; -- (NSString*) getMetricPath; -- (BOOL) getTestStatus; +- (NSString*)getStyleResultPath; +- (NSString*)getMetricResultPath; +- (NSString*)getMetricPath; +- (BOOL)getTestStatus; @end diff --git a/render-test/ios/ios_test_runner.cpp b/render-test/ios/ios_test_runner.cpp index 5947d0525..66cac4981 100644 --- a/render-test/ios/ios_test_runner.cpp +++ b/render-test/ios/ios_test_runner.cpp @@ -20,13 +20,16 @@ bool TestRunner::startTest(const std::string& manifestBasePath) { int finishedTestCount = 0; std::function testStatus = [&]() { - mbgl::Log::Info(mbgl::Event::General, "Current finished tests number is '" + std::to_string(++finishedTestCount) + "' "); + mbgl::Log::Info(mbgl::Event::General, + "Current finished tests number is '" + std::to_string(++finishedTestCount) + "' "); }; mbgl::Log::Info(mbgl::Event::General, "Start running RenderTestRunner with manifest: '" + manifest + "' "); auto result = mbgl::runRenderTests(static_cast(argv.size() - 1), argv.data(), testStatus); - mbgl::Log::Info(mbgl::Event::General, "End running RenderTestRunner with manifest: '" + manifest + "' with result value " + std::to_string(result)); + mbgl::Log::Info(mbgl::Event::General, + "End running RenderTestRunner with manifest: '" + manifest + "' with result value " + + std::to_string(result)); return result == 0; };