summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/include/MGLGeometry.h42
-rw-r--r--platform/darwin/include/MGLOfflinePack.h21
-rw-r--r--platform/darwin/include/MGLTypes.h5
-rw-r--r--platform/darwin/include/NSValue+MGLAdditions.h75
-rw-r--r--platform/darwin/src/MGLCoordinateFormatter.m2
-rw-r--r--platform/darwin/src/MGLGeometry.mm35
-rw-r--r--platform/darwin/src/MGLOfflinePack.mm14
-rw-r--r--platform/darwin/src/MGLOfflineStorage.mm1
-rw-r--r--platform/darwin/src/NSValue+MGLAdditions.m49
-rw-r--r--platform/darwin/test/MGLGeometryTests.mm5
10 files changed, 134 insertions, 115 deletions
diff --git a/platform/darwin/include/MGLGeometry.h b/platform/darwin/include/MGLGeometry.h
index 1c1bf65efb..7ad5140400 100644
--- a/platform/darwin/include/MGLGeometry.h
+++ b/platform/darwin/include/MGLGeometry.h
@@ -100,48 +100,6 @@ NS_INLINE CLLocationDegrees MGLDegreesFromRadians(CGFloat radians) {
*/
@interface NSValue (MGLGeometryAdditions)
-/**
- Creates a new value object containing the specified Core Location geographic
- coordinate structure.
-
- @param coordinate The value for the new object.
- @return A new value object that contains the geographic coordinate information.
- */
-+ (instancetype)valueWithMGLCoordinate:(CLLocationCoordinate2D)coordinate;
-
-/**
- The Core Location geographic coordinate structure representation of the value.
- */
-@property (readonly) CLLocationCoordinate2D MGLCoordinateValue;
-
-/**
- Creates a new value object containing the specified Mapbox coordinate span
- structure.
-
- @param span The value for the new object.
- @return A new value object that contains the coordinate span information.
- */
-+ (instancetype)valueWithMGLCoordinateSpan:(MGLCoordinateSpan)span;
-
-/**
- The Mapbox coordinate span structure representation of the value.
- */
-@property (readonly) MGLCoordinateSpan MGLCoordinateSpanValue;
-
-/**
- Creates a new value object containing the specified Mapbox coordinate bounds
- structure.
-
- @param bounds The value for the new object.
- @return A new value object that contains the coordinate bounds information.
- */
-+ (instancetype)valueWithMGLCoordinateBounds:(MGLCoordinateBounds)bounds;
-
-/**
- The Mapbox coordinate bounds structure representation of the value.
- */
-@property (readonly) MGLCoordinateBounds MGLCoordinateBoundsValue;
-
@end
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/include/MGLOfflinePack.h b/platform/darwin/include/MGLOfflinePack.h
index 783650590a..083e050ddd 100644
--- a/platform/darwin/include/MGLOfflinePack.h
+++ b/platform/darwin/include/MGLOfflinePack.h
@@ -177,25 +177,4 @@ typedef struct MGLOfflinePackProgress {
@end
-/**
- Methods for round-tripping `MGLOfflinePackProgress` values.
- */
-@interface NSValue (MGLOfflinePackAdditions)
-
-/**
- Creates a new value object containing the given `MGLOfflinePackProgress`
- structure.
-
- @param progress The value for the new object.
- @return A new value object that contains the offline pack progress information.
- */
-+ (NSValue *)valueWithMGLOfflinePackProgress:(MGLOfflinePackProgress)progress;
-
-/**
- The `MGLOfflinePackProgress` structure representation of the value.
- */
-@property (readonly) MGLOfflinePackProgress MGLOfflinePackProgressValue;
-
-@end
-
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/include/MGLTypes.h b/platform/darwin/include/MGLTypes.h
index 9617b069da..746cb686c0 100644
--- a/platform/darwin/include/MGLTypes.h
+++ b/platform/darwin/include/MGLTypes.h
@@ -17,10 +17,15 @@ NS_ASSUME_NONNULL_BEGIN
/** Indicates an error occurred in the Mapbox SDK. */
extern NSString * const MGLErrorDomain;
+/** Error constants for the Mapbox SDK. */
typedef NS_ENUM(NSInteger, MGLErrorCode) {
+ /** An unknown error occurred. */
MGLErrorCodeUnknown = -1,
+ /** The resource could not be found. */
MGLErrorCodeNotFound = 1,
+ /** The connection received an invalid server response. */
MGLErrorCodeBadServerResponse = 2,
+ /** An attempt to establish a connection failed. */
MGLErrorCodeConnectionFailed = 3,
};
diff --git a/platform/darwin/include/NSValue+MGLAdditions.h b/platform/darwin/include/NSValue+MGLAdditions.h
new file mode 100644
index 0000000000..4a97c8e115
--- /dev/null
+++ b/platform/darwin/include/NSValue+MGLAdditions.h
@@ -0,0 +1,75 @@
+#import <Foundation/Foundation.h>
+
+#import "MGLGeometry.h"
+#import "MGLOfflinePack.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ Methods for round-tripping values for Mapbox-defined types.
+ */
+@interface NSValue (MGLAdditions)
+
+#pragma mark Working with Geographic Coordinate Values
+
+/**
+ Creates a new value object containing the specified Core Location geographic
+ coordinate structure.
+
+ @param coordinate The value for the new object.
+ @return A new value object that contains the geographic coordinate information.
+ */
++ (instancetype)valueWithMGLCoordinate:(CLLocationCoordinate2D)coordinate;
+
+/**
+ The Core Location geographic coordinate structure representation of the value.
+ */
+@property (readonly) CLLocationCoordinate2D MGLCoordinateValue;
+
+/**
+ Creates a new value object containing the specified Mapbox coordinate span
+ structure.
+
+ @param span The value for the new object.
+ @return A new value object that contains the coordinate span information.
+ */
++ (instancetype)valueWithMGLCoordinateSpan:(MGLCoordinateSpan)span;
+
+/**
+ The Mapbox coordinate span structure representation of the value.
+ */
+@property (readonly) MGLCoordinateSpan MGLCoordinateSpanValue;
+
+/**
+ Creates a new value object containing the specified Mapbox coordinate bounds
+ structure.
+
+ @param bounds The value for the new object.
+ @return A new value object that contains the coordinate bounds information.
+ */
++ (instancetype)valueWithMGLCoordinateBounds:(MGLCoordinateBounds)bounds;
+
+/**
+ The Mapbox coordinate bounds structure representation of the value.
+ */
+@property (readonly) MGLCoordinateBounds MGLCoordinateBoundsValue;
+
+#pragma mark Working with Offline Map Values
+
+/**
+ Creates a new value object containing the given `MGLOfflinePackProgress`
+ structure.
+
+ @param progress The value for the new object.
+ @return A new value object that contains the offline pack progress information.
+ */
++ (NSValue *)valueWithMGLOfflinePackProgress:(MGLOfflinePackProgress)progress;
+
+/**
+ The `MGLOfflinePackProgress` structure representation of the value.
+ */
+@property (readonly) MGLOfflinePackProgress MGLOfflinePackProgressValue;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLCoordinateFormatter.m b/platform/darwin/src/MGLCoordinateFormatter.m
index 847b5dfe76..259917717f 100644
--- a/platform/darwin/src/MGLCoordinateFormatter.m
+++ b/platform/darwin/src/MGLCoordinateFormatter.m
@@ -1,6 +1,6 @@
#import "MGLCoordinateFormatter.h"
-#import "MGLGeometry.h"
+#import "NSValue+MGLAdditions.h"
@implementation MGLCoordinateFormatter {
NSNumberFormatter *_numberFormatter;
diff --git a/platform/darwin/src/MGLGeometry.mm b/platform/darwin/src/MGLGeometry.mm
index 9907f14252..70f00afd2f 100644
--- a/platform/darwin/src/MGLGeometry.mm
+++ b/platform/darwin/src/MGLGeometry.mm
@@ -44,38 +44,3 @@ double MGLZoomLevelForAltitude(CLLocationDistance altitude, CGFloat pitch, CLLoc
CGFloat mapPixelWidthAtZoom = std::cos(MGLRadiansFromDegrees(latitude)) * mbgl::util::M2PI * mbgl::util::EARTH_RADIUS_M / metersPerPixel;
return ::log2(mapPixelWidthAtZoom / mbgl::util::tileSize);
}
-
-@implementation NSValue (MGLGeometryAdditions)
-
-+ (instancetype)valueWithMGLCoordinate:(CLLocationCoordinate2D)coordinate {
- return [self valueWithBytes:&coordinate objCType:@encode(CLLocationCoordinate2D)];
-}
-
-- (CLLocationCoordinate2D)MGLCoordinateValue {
- CLLocationCoordinate2D coordinate;
- [self getValue:&coordinate];
- return coordinate;
-}
-
-+ (instancetype)valueWithMGLCoordinateSpan:(MGLCoordinateSpan)span {
- return [self valueWithBytes:&span objCType:@encode(MGLCoordinateSpan)];
-}
-
-- (MGLCoordinateSpan)MGLCoordinateSpanValue {
- MGLCoordinateSpan span;
- [self getValue:&span];
- return span;
-}
-
-+ (instancetype)valueWithMGLCoordinateBounds:(MGLCoordinateBounds)bounds {
- return [self valueWithBytes:&bounds objCType:@encode(MGLCoordinateBounds)];
-}
-
-- (MGLCoordinateBounds)MGLCoordinateBoundsValue {
- MGLCoordinateBounds bounds;
- [self getValue:&bounds];
- return bounds;
-}
-
-@end
-
diff --git a/platform/darwin/src/MGLOfflinePack.mm b/platform/darwin/src/MGLOfflinePack.mm
index 13032a6ec6..9c8396f728 100644
--- a/platform/darwin/src/MGLOfflinePack.mm
+++ b/platform/darwin/src/MGLOfflinePack.mm
@@ -202,17 +202,3 @@ void MBGLOfflineRegionObserver::mapboxTileCountLimitExceeded(uint64_t limit) {
[pack.delegate offlinePack:pack didReceiveMaximumAllowedMapboxTiles:limit];
});
}
-
-@implementation NSValue (MGLOfflinePackAdditions)
-
-+ (NSValue *)valueWithMGLOfflinePackProgress:(MGLOfflinePackProgress)progress {
- return [NSValue value:&progress withObjCType:@encode(MGLOfflinePackProgress)];
-}
-
-- (MGLOfflinePackProgress)MGLOfflinePackProgressValue {
- MGLOfflinePackProgress progress;
- [self getValue:&progress];
- return progress;
-}
-
-@end
diff --git a/platform/darwin/src/MGLOfflineStorage.mm b/platform/darwin/src/MGLOfflineStorage.mm
index 89bf050249..f09b03def1 100644
--- a/platform/darwin/src/MGLOfflineStorage.mm
+++ b/platform/darwin/src/MGLOfflineStorage.mm
@@ -5,6 +5,7 @@
#import "MGLOfflinePack_Private.h"
#import "MGLOfflineRegion_Private.h"
#import "MGLTilePyramidOfflineRegion.h"
+#import "NSValue+MGLAdditions.h"
#include <mbgl/util/string.hpp>
diff --git a/platform/darwin/src/NSValue+MGLAdditions.m b/platform/darwin/src/NSValue+MGLAdditions.m
new file mode 100644
index 0000000000..0d2128bea8
--- /dev/null
+++ b/platform/darwin/src/NSValue+MGLAdditions.m
@@ -0,0 +1,49 @@
+#import "NSValue+MGLAdditions.h"
+
+@implementation NSValue (MGLAdditions)
+
+#pragma mark Geometry
+
++ (instancetype)valueWithMGLCoordinate:(CLLocationCoordinate2D)coordinate {
+ return [self valueWithBytes:&coordinate objCType:@encode(CLLocationCoordinate2D)];
+}
+
+- (CLLocationCoordinate2D)MGLCoordinateValue {
+ CLLocationCoordinate2D coordinate;
+ [self getValue:&coordinate];
+ return coordinate;
+}
+
++ (instancetype)valueWithMGLCoordinateSpan:(MGLCoordinateSpan)span {
+ return [self valueWithBytes:&span objCType:@encode(MGLCoordinateSpan)];
+}
+
+- (MGLCoordinateSpan)MGLCoordinateSpanValue {
+ MGLCoordinateSpan span;
+ [self getValue:&span];
+ return span;
+}
+
++ (instancetype)valueWithMGLCoordinateBounds:(MGLCoordinateBounds)bounds {
+ return [self valueWithBytes:&bounds objCType:@encode(MGLCoordinateBounds)];
+}
+
+- (MGLCoordinateBounds)MGLCoordinateBoundsValue {
+ MGLCoordinateBounds bounds;
+ [self getValue:&bounds];
+ return bounds;
+}
+
+#pragma mark Offline maps
+
++ (NSValue *)valueWithMGLOfflinePackProgress:(MGLOfflinePackProgress)progress {
+ return [NSValue value:&progress withObjCType:@encode(MGLOfflinePackProgress)];
+}
+
+- (MGLOfflinePackProgress)MGLOfflinePackProgressValue {
+ MGLOfflinePackProgress progress;
+ [self getValue:&progress];
+ return progress;
+}
+
+@end
diff --git a/platform/darwin/test/MGLGeometryTests.mm b/platform/darwin/test/MGLGeometryTests.mm
index b9205e8d9d..e76c67c5c1 100644
--- a/platform/darwin/test/MGLGeometryTests.mm
+++ b/platform/darwin/test/MGLGeometryTests.mm
@@ -1,7 +1,8 @@
-#import "../../darwin/src/MGLGeometry_Private.h"
-
+#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
+#import "../../darwin/src/MGLGeometry_Private.h"
+
@interface MGLGeometryTests : XCTestCase
@end