Formatting Objective-C and Objective-C++ (#2492)

This commit is contained in:
Bart Louwers
2024-06-11 19:01:50 +02:00
committed by GitHub
parent 7437d800f6
commit 7b09da234a
153 changed files with 3099 additions and 2694 deletions

View File

@@ -19,4 +19,5 @@ Language: Cpp
---
Language: ObjC
BasedOnStyle: Google
ObjCSpaceAfterProperty: true
...

View File

@@ -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:

View File

@@ -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

View File

@@ -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;

View File

@@ -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<CFDataRef, CFTypeRef, CFRelease>;
CFDataHandle data(CFDataCreateWithBytesNoCopy(
kCFAllocatorDefault, reinterpret_cast<const unsigned char*>(source.data()), source.size(),
kCFAllocatorNull));
@@ -19,13 +19,14 @@ namespace {
template <typename HandleType, typename ReleaserArgumentType, void (*Releaser)(ReleaserArgumentType)>
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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import <TargetConditionals.h>
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

View File

@@ -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<MLNAttributedExpressionKey, NSExpression *> *attributes;
@property (strong, nonatomic, readonly)
NSDictionary<MLNAttributedExpressionKey, NSExpression *> *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<MLNAttributedExpressionKey, NSExpression *> *attributes;
@property (strong, nonatomic, readonly)
NSDictionary<MLNAttributedExpressionKey, NSExpression *> *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 <MLNAttributedExpressionKey, NSExpression *> *)attrs;
- (instancetype)
initWithExpression:(NSExpression *)expression
attributes:(nonnull NSDictionary<MLNAttributedExpressionKey, NSExpression *> *)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<NSString*> *)fontNames fontScale:(nullable NSNumber *)fontScale;
+ (instancetype)attributedExpression:(NSExpression *)expression
fontNames:(nullable NSArray<NSString *> *)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 <MLNAttributedExpressionKey, NSExpression *> *)attrs;
+ (instancetype)
attributedExpression:(NSExpression *)expression
attributes:(nonnull NSDictionary<MLNAttributedExpressionKey, NSExpression *> *)attrs;
@end

View File

@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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;

View File

@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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<MLNAttributionInfo *> *)attributionInfosFromHTMLString:(nullable NSString *)htmlString fontSize:(CGFloat)fontSize linkColor:(nullable MLNColor *)linkColor;
+ (NSArray<MLNAttributionInfo *> *)attributionInfosFromHTMLString:(nullable NSString *)htmlString
fontSize:(CGFloat)fontSize
linkColor:(nullable MLNColor *)linkColor;
+ (NSAttributedString *)attributedStringForAttributionInfos:(NSArray<MLNAttributionInfo *> *)attributionInfos;
+ (NSAttributedString *)attributedStringForAttributionInfos:
(NSArray<MLNAttributionInfo *> *)attributionInfos;
@end

View File

@@ -2,18 +2,16 @@
#import <MetalKit/MetalKit.h>
typedef struct
{
typedef struct {
MTKView *mtkView;
id <MTLDevice> device;
id<MTLDevice> device;
MTLRenderPassDescriptor *renderPassDescriptor;
id <MTLCommandBuffer> commandBuffer;
id<MTLCommandBuffer> commandBuffer;
} MLNBackendResource;
#else
typedef struct
{
typedef struct {
} MLNBackendResource;
#endif

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -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 {

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -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<MLNShape <MLNFeature> *>*)featuresInTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel;
- (NSArray<MLNShape<MLNFeature> *> *)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<MLNShape <MLNFeature> *>*)featuresInCoordinateBounds:(MLNCoordinateBounds)bounds zoomLevel:(NSUInteger)zoomLevel;
- (NSArray<MLNShape<MLNFeature> *> *)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
<a href="https://www.mapbox.com/vector-tiles/">Mapbox Vector Tiles</a>. For
<a href="http://geojson.org/">GeoJSON</a> 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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson">style
specification</a>.
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<MLNShapeSourceOption, id> *)options NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithIdentifier:(NSString *)identifier
options:(nullable NSDictionary<MLNShapeSourceOption, id> *)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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson">style
specification</a>.
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<MLNComputedShapeSourceDataSource>)dataSource options:(nullable NSDictionary<MLNShapeSourceOption, id> *)options;
- (instancetype)initWithIdentifier:(NSString *)identifier
dataSource:(id<MLNComputedShapeSourceDataSource>)dataSource
options:(nullable NSDictionary<MLNShapeSourceOption, id> *)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<MLNShape <MLNFeature> *>*)features inTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel;
- (void)setFeatures:(NSArray<MLNShape<MLNFeature> *> *)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<MLNComputedShapeSourceDataSource> dataSource;

View File

@@ -1,12 +1,13 @@
#import "MLNComputedShapeSource.h"
#import "MLNFoundation.h"
#import "MLNTypes.h"
#import "MLNComputedShapeSource.h"
#include <mbgl/style/sources/custom_geometry_source.hpp>
NS_ASSUME_NONNULL_BEGIN
MLN_EXPORT
mbgl::style::CustomGeometrySource::Options MBGLCustomGeometrySourceOptionsFromDictionary(NSDictionary<MLNShapeSourceOption, id> *options);
mbgl::style::CustomGeometrySource::Options MBGLCustomGeometrySourceOptionsFromDictionary(
NSDictionary<MLNShapeSourceOption, id> *options);
NS_ASSUME_NONNULL_END

View File

@@ -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<Holder> {
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<size_t>::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<size_t>::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<Holder> 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<Holder> 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 <class Fn>
static std::optional<Error> eachMember(const Holder& holder, Fn&& visit) {
template <class Fn>
static std::optional<Error> 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<const char *>([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<const char*>([key UTF8String])), obj);
if (result) {
*stop = YES;
}
}];
return {};
}
static std::optional<bool> toBool(const Holder& holder) {
const id value = holder.value;
if (_isBool(value)) {
return ((NSNumber*)value).boolValue;
} else {
return {};
}
}
static std::optional<float> toNumber(const Holder& holder) {
const id value = holder.value;
if (_isNumber(value)) {
return ((NSNumber*)value).floatValue;
} else {
return {};
}
}
static std::optional<double> toDouble(const Holder& holder) {
const id value = holder.value;
if (_isNumber(value)) {
return ((NSNumber*)value).doubleValue;
} else {
return {};
}
}
static std::optional<std::string> toString(const Holder& holder) {
const id value = holder.value;
if (_isString(value)) {
return std::string(static_cast<const char*>([value UTF8String]));
} else {
return {};
}
}
static std::optional<mbgl::Value> 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<GeoJSON> 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<bool> 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<float> 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<double> toDouble(const Holder& holder) {
const id value = holder.value;
if (_isNumber(value)) {
return ((NSNumber *)value).doubleValue;
} else {
return {};
}
}
static std::optional<std::string> toString(const Holder& holder) {
const id value = holder.value;
if (_isString(value)) {
return std::string(static_cast<const char *>([value UTF8String]));
} else {
return {};
}
}
static std::optional<mbgl::Value> 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<GeoJSON> 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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -1,10 +1,9 @@
#import <Foundation/Foundation.h>
#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

View File

@@ -5,11 +5,11 @@
#include <mbgl/layermanager/custom_drawable_layer_factory.hpp>
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

View File

@@ -1,11 +1,11 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import "MLNFoundation.h"
#import "MLNStyleValue.h"
#import "MLNStyleLayer.h"
#import "MLNGeometry.h"
#import "MLNStyleLayer.h"
#import "MLNStyleValue.h"
#if MLN_RENDER_BACKEND_METAL
#import <MetalKit/MetalKit.h>
@@ -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

View File

@@ -5,11 +5,11 @@
#include <mbgl/layermanager/custom_layer_factory.hpp>
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

View File

@@ -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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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.
*/

View File

@@ -1,12 +1,12 @@
#import <Foundation/Foundation.h>
#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
<a href="https://github.com/mapbox/vector-tile-spec/tree/master/2.1#42-features">feature identifier</a>
<a href="https://github.com/mapbox/vector-tile-spec/tree/master/2.1#42-features">feature
identifier</a>
(`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
<tr><th>In the tile source</th><th>This property</th></tr>
</thead>
<tbody>
<tr><td>Integer</td> <td><code>NSNumber</code> (use the <code>unsignedLongLongValue</code> or <code>longLongValue</code> property)</td></tr>
<tr><td>Floating-point number</td> <td><code>NSNumber</code> (use the <code>doubleValue</code> property)</td></tr>
<tr><td>String</td> <td><code>NSString</code></td></tr>
<tr><td>Integer</td> <td><code>NSNumber</code> (use the
<code>unsignedLongLongValue</code> or <code>longLongValue</code> property)</td></tr>
<tr><td>Floating-point number</td> <td><code>NSNumber</code> (use the <code>doubleValue</code>
property)</td></tr> <tr><td>String</td> <td><code>NSString</code></td></tr>
</tbody>
</table>
@@ -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
</thead>
<tbody>
<tr><td>Null</td> <td><code>NSNull</code></td></tr>
<tr><td>Boolean</td> <td><code>NSNumber</code> (use the <code>boolValue</code> property)</td></tr>
<tr><td>Integer</td> <td><code>NSNumber</code> (use the <code>unsignedLongLongValue</code> or <code>longLongValue</code> property)</td></tr>
<tr><td>Floating-point number</td> <td><code>NSNumber</code> (use the <code>doubleValue</code> property)</td></tr>
<tr><td>String</td> <td><code>NSString</code></td></tr>
<tr><td>Boolean</td> <td><code>NSNumber</code> (use the <code>boolValue</code>
property)</td></tr> <tr><td>Integer</td> <td><code>NSNumber</code> (use the
<code>unsignedLongLongValue</code> or <code>longLongValue</code> property)</td></tr>
<tr><td>Floating-point number</td> <td><code>NSNumber</code> (use the <code>doubleValue</code>
property)</td></tr> <tr><td>String</td> <td><code>NSString</code></td></tr>
</tbody>
</table>
@@ -133,7 +136,7 @@ NS_ASSUME_NONNULL_BEGIN
and
<a href="https://www.mapbox.com/vector-tiles/mapbox-terrain/">Mapbox Terrain</a>
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
<a href="https://tools.ietf.org/html/rfc7946#section-3.1.4">LineString</a>
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
<a href="https://tools.ietf.org/html/rfc7946#section-3.3">feature collection</a>
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.

View File

@@ -1,10 +1,10 @@
#import "MLNFoundation.h"
#import "MLNFeature.h"
#import "MLNFoundation.h"
#import "MLNShape.h"
#import <mbgl/util/geo.hpp>
#import <mbgl/util/feature.hpp>
#import <mbgl/style/conversion/geojson.hpp>
#import <mbgl/util/feature.hpp>
#import <mbgl/util/geo.hpp>
NS_ASSUME_NONNULL_BEGIN
@@ -13,73 +13,79 @@ NS_ASSUME_NONNULL_BEGIN
vector tile features.
*/
MLN_EXPORT
NSArray<MLNShape <MLNFeature> *> *MLNFeaturesFromMBGLFeatures(const std::vector<mbgl::Feature> &features);
NSArray<MLNShape<MLNFeature> *> *MLNFeaturesFromMBGLFeatures(
const std::vector<mbgl::Feature> &features);
/**
Returns an array of `MLNFeature` objects converted from the given vector of
vector tile features.
*/
MLN_EXPORT
NSArray<MLNShape <MLNFeature> *> *MLNFeaturesFromMBGLFeatures(const std::vector<mbgl::GeoJSONFeature> &features);
NSArray<MLNShape<MLNFeature> *> *MLNFeaturesFromMBGLFeatures(
const std::vector<mbgl::GeoJSONFeature> &features);
/**
Returns an `MLNFeature` object converted from the given mbgl::GeoJSONFeature
*/
MLN_EXPORT
id <MLNFeature> MLNFeatureFromMBGLFeature(const mbgl::GeoJSONFeature &feature);
id<MLNFeature> 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<NSString *, id> *NSDictionaryFeatureForGeometry(NSDictionary *geometry, NSDictionary *attributes, id identifier);
NSDictionary<NSString *, id> *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<Class> *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<Class> *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; \
}

View File

@@ -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

View File

@@ -2,4 +2,4 @@
#import <Foundation/Foundation.h>
#define MLN_EXPORT __attribute__((visibility ("default")))
#define MLN_EXPORT __attribute__((visibility("default")))

View File

@@ -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<proto>)([temp##__LINE__ conformsToProtocol:@protocol(proto)] ? temp##__LINE__ : nil); \
})

View File

@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -2,7 +2,7 @@
#import <TargetConditionals.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#endif
#import <mbgl/util/geo.hpp>
@@ -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<double> MLNPointFromLocationCoordinate2D(CLLocationCoordinate2D coordinate) {
return mbgl::Point<double>(coordinate.longitude, coordinate.latitude);
return mbgl::Point<double>(coordinate.longitude, coordinate.latitude);
}
NS_INLINE CLLocationCoordinate2D MLNLocationCoordinate2DFromPoint(mbgl::Point<double> 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<mbgl::LatLng, 4> 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<mbgl::LatLng, 4> 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<mbgl::La
Considers extended coordinates.
*/
NS_INLINE BOOL MLNLocationCoordinate2DIsValid(CLLocationCoordinate2D coordinate) {
return (coordinate.latitude <= 90.0 &&
coordinate.latitude >= -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.

View File

@@ -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
<a href="https://maplibre.org/maplibre-style-spec/#sources-image"><code>image</code></a>
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.

View File

@@ -3,10 +3,10 @@
#import "MLNLight.h"
namespace mbgl {
namespace style {
class Light;
}
namespace style {
class Light;
}
} // namespace mbgl
@interface MLNLight (Private)

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
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<MLNLocationManager>)manager
didUpdateHeading:(CLHeading *)newHeading;
- (void)locationManager:(id<MLNLocationManager>)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<MLNLocationManager>)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<MLNLocationManager>)manager
didFailWithError:(nonnull NSError *)error;
- (void)locationManager:(id<MLNLocationManager>)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<MLNLocationManager>)manager;
#endif
#endif
@optional

View File

@@ -1,5 +1,5 @@
#import "MLNLocationManager.h"
@interface MLNCLLocationManager : NSObject<MLNLocationManager>
@interface MLNCLLocationManager : NSObject <MLNLocationManager>
@end

View File

@@ -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;

View File

@@ -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

View File

@@ -1,6 +1,6 @@
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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.

View File

@@ -1,8 +1,8 @@
#import <Foundation/Foundation.h>
#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 <MLNMapSnapshotterDelegate> delegate;
@property (nonatomic, weak) id<MLNMapSnapshotterDelegate> 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.
*/

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -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 <MLNMultiPointDelegate>)delegate;
- (mbgl::Annotation)annotationObjectWithDelegate:(id<MLNMultiPointDelegate>)delegate;
@end

View File

@@ -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.

View File

@@ -1,20 +1,21 @@
#import "MLNNetworkConfiguration.h"
#include <mbgl/interface/native_apple_interface.h>
#import "MLNNetworkConfiguration.h"
NS_ASSUME_NONNULL_BEGIN
@class MLNNetworkConfiguration;
@protocol MLNNetworkConfigurationMetricsDelegate <NSObject>
- (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<NSString*, NSDictionary*> *events;
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSDictionary *> *events;
@property (nonatomic, weak) id<MLNNetworkConfigurationMetricsDelegate> metricsDelegate;
- (void)resetNativeNetworkManagerDelegate;

View File

@@ -1,8 +1,8 @@
#import <Foundation/Foundation.h>
#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 <MLNOfflineRegion> region;
@property (nonatomic, readonly) id<MLNOfflineRegion> 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.

View File

@@ -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.
*/

View File

@@ -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<MLNOfflinePack *> * _Nullable packs, NSError * _Nullable error);
typedef void (^MLNBatchedOfflinePackAdditionCompletionHandler)(
NSURL *fileURL, NSArray<MLNOfflinePack *> *_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 <a href="https://www.mapbox.com/pricing/">our pricing page</a> 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<MLNOfflineStorageDelegate> delegate;
@property (nonatomic, weak, nullable) IBOutlet id<MLNOfflineStorageDelegate> 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 <MLNOfflineRegion>)region withContext:(NSData *)context completionHandler:(nullable MLNOfflinePackAdditionCompletionHandler)completion;
- (void)addPackForRegion:(id<MLNOfflineRegion>)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

View File

@@ -2,8 +2,8 @@
#import "MLNOfflinePack.h"
#include <mbgl/storage/online_file_source.hpp>
#include <mbgl/storage/database_file_source.hpp>
#include <mbgl/storage/online_file_source.hpp>
#include "MLNSettings_Private.h"
@@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic) std::shared_ptr<mbgl::FileSource> mbglFileSource;
- (void)getPacksWithCompletionHandler:(void (^)(NSArray<MLNOfflinePack *> *packs, NSError * _Nullable error))completion;
- (void)getPacksWithCompletionHandler:(void (^)(NSArray<MLNOfflinePack *> *packs,
NSError *_Nullable error))completion;
@end

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "MLNFoundation.h"
#import "MLNShape.h"
@@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
A point shape is known as a
<a href="https://tools.ietf.org/html/rfc7946#section-3.1.2">Point</a> 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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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;

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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<MLNPolygon *> *)interiorPolygons;
+ (instancetype)polygonWithCoordinates:(const CLLocationCoordinate2D *)coords
count:(NSUInteger)count
interiorPolygons:(nullable NSArray<MLNPolygon *> *)interiorPolygons;
@end

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#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
<a href="https://tools.ietf.org/html/rfc7946#section-3.1.4">LineString</a>
geometry in GeoJSON.
#### Related examples
- <doc:LineOnUserTap>
@@ -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

View File

@@ -9,4 +9,3 @@ NS_ASSUME_NONNULL_BEGIN
@end
NS_ASSUME_NONNULL_END

View File

@@ -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
<a href="https://docs.mapbox.com/help/troubleshooting/access-elevation-data/#mapbox-terrain-rgb">Mapbox Terrain-RGB</a>.
<a
href="https://docs.mapbox.com/help/troubleshooting/access-elevation-data/#mapbox-terrain-rgb">Mapbox
Terrain-RGB</a>.
### Example

View File

@@ -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<NSString *> *)tileURLTemplates options:(nullable NSDictionary<MLNTileSourceOption, id> *)options NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithIdentifier:(NSString *)identifier
tileURLTemplates:(NSArray<NSString *> *)tileURLTemplates
options:(nullable NSDictionary<MLNTileSourceOption, id> *)options
NS_DESIGNATED_INITIALIZER;
@end

View File

@@ -1,14 +1,14 @@
#import "MLNRasterTileSource.h"
#include <memory>
#include <mbgl/util/variant.hpp>
#include <memory>
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<mbgl::style::RasterSource>)pendingSourceWithIdentifier:(NSString *)identifier urlOrTileset:(mbgl::variant<std::string, mbgl::Tileset>)urlOrTileset tileSize:(uint16_t)tileSize;
- (std::unique_ptr<mbgl::style::RasterSource>)
pendingSourceWithIdentifier:(NSString *)identifier
urlOrTileset:(mbgl::variant<std::string, mbgl::Tileset>)urlOrTileset
tileSize:(uint16_t)tileSize;
@end

View File

@@ -28,66 +28,65 @@
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
/**
* 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

View File

@@ -1,5 +1,5 @@
#import "MLNFoundation.h"
#import <Foundation/Foundation.h>
#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.
*/

View File

@@ -1,73 +1,67 @@
#include <mbgl/gfx/backend_scope.hpp>
#include <mbgl/gfx/renderer_backend.hpp>
#include <mbgl/renderer/renderer.hpp>
#include <mbgl/renderer/renderer_frontend.hpp>
#include <mbgl/gfx/renderer_backend.hpp>
#include <mbgl/util/async_task.hpp>
/**
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<mbgl::Renderer> 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<mbgl::Renderer> 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<mbgl::UpdateParameters> updateParameters_) override {
updateParameters = std::move(updateParameters_);
if (asyncInvalidate) {
asyncInvalidate->send();
} else {
[nativeView setNeedsRerender];
}
}
void update(std::shared_ptr<mbgl::UpdateParameters> 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<mbgl::Renderer> renderer;
__weak MLNMapView *nativeView = nullptr;
mbgl::gfx::RendererBackend& mbglBackend;
std::shared_ptr<mbgl::UpdateParameters> updateParameters;
std::optional<mbgl::util::AsyncTask> 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<mbgl::Renderer> renderer;
__weak MLNMapView* nativeView = nullptr;
mbgl::gfx::RendererBackend& mbglBackend;
std::shared_ptr<mbgl::UpdateParameters> updateParameters;
std::optional<mbgl::util::AsyncTask> asyncInvalidate;
};

View File

@@ -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

View File

@@ -1,6 +1,6 @@
#import "MLNSettings.h"
#import <mbgl/util/tile_server_options.hpp>
#import <mbgl/util/default_style.hpp>
#import <mbgl/util/tile_server_options.hpp>
#import "MLNSettings.h"
NS_ASSUME_NONNULL_BEGIN

View File

@@ -1,7 +1,7 @@
#import <Foundation/Foundation.h>
#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

View File

@@ -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

View File

@@ -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

View File

@@ -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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-cluster"><code>cluster</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/#sources-geojson-cluster"><code>cluster</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-clusterProperties"><code>clusterProperties</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/#sources-geojson-clusterProperties"><code>clusterProperties</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-clusterMaxZoom"><code>clusterMaxZoom</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/#sources-geojson-clusterMaxZoom"><code>clusterMaxZoom</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-minzoom"><code>minzoom</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/#sources-geojson-minzoom"><code>minzoom</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-maxzoom"><code>maxzoom</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/#sources-geojson-maxzoom"><code>maxzoom</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-buffer"><code>buffer</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/#sources-geojson-tolerance"><code>tolerance</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/#sources-geojson-tolerance"><code>tolerance</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/sources/#geojson-lineMetrics"><code>lineMetrics</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/sources/#geojson-lineMetrics"><code>lineMetrics</code></a>
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<MLNShapeSourceOption, id> *)options NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithIdentifier:(NSString *)identifier
URL:(NSURL *)url
options:(nullable NSDictionary<MLNShapeSourceOption, id> *)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<MLNShapeSourceOption, id> *)options NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithIdentifier:(NSString *)identifier
shape:(nullable MLNShape *)shape
options:(nullable NSDictionary<MLNShapeSourceOption, id> *)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<MLNShape<MLNFeature> *> *)features options:(nullable NSDictionary<MLNShapeSourceOption, id> *)options;
- (instancetype)initWithIdentifier:(NSString *)identifier
features:(NSArray<MLNShape<MLNFeature> *> *)features
options:(nullable NSDictionary<MLNShapeSourceOption, id> *)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<MLNShape *> *)shapes options:(nullable NSDictionary<MLNShapeSourceOption, id> *)options;
- (instancetype)initWithIdentifier:(NSString *)identifier
shapes:(NSArray<MLNShape *> *)shapes
options:(nullable NSDictionary<MLNShapeSourceOption, id> *)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<id <MLNFeature>> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate;
- (NSArray<id<MLNFeature>> *)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<id <MLNFeature>> *)leavesOfCluster:(MLNPointFeatureCluster *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit;
- (NSArray<id<MLNFeature>> *)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.
*/

View File

@@ -1,17 +1,18 @@
#include <mbgl/util/immutable.hpp>
#import "MLNFoundation.h"
#import "MLNShapeSource.h"
#include <mbgl/util/immutable.hpp>
NS_ASSUME_NONNULL_BEGIN
namespace mbgl {
namespace style {
struct GeoJSONOptions;
}
namespace style {
struct GeoJSONOptions;
}
} // namespace mbgl
MLN_EXPORT
mbgl::Immutable<mbgl::style::GeoJSONOptions> MLNGeoJSONOptionsFromDictionary(NSDictionary<MLNShapeSourceOption, id> *options);
mbgl::Immutable<mbgl::style::GeoJSONOptions> MLNGeoJSONOptionsFromDictionary(
NSDictionary<MLNShapeSourceOption, id> *options);
@interface MLNShapeSource (Private)
@@ -21,7 +22,7 @@ mbgl::Immutable<mbgl::style::GeoJSONOptions> 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.
*/

View File

@@ -1,8 +1,8 @@
#import "MLNShape.h"
#import <mbgl/util/geo.hpp>
#import <mbgl/util/geojson.hpp>
#import <mbgl/util/geometry.hpp>
#import <mbgl/util/geo.hpp>
bool operator==(const CLLocationCoordinate2D lhs, const CLLocationCoordinate2D rhs);

View File

@@ -2,38 +2,37 @@
#include <memory>
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 <MLNStylable>)stylable;
- (instancetype)initWithRawSource:(mbgl::style::Source *)rawSource
stylable:(nullable id<MLNStylable>)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 <MLNStylable> stylable;
@property (nonatomic, readonly, weak) id<MLNStylable> 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 <MLNStylable>)mapView;
- (void)addToStylable:(id<MLNStylable>)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 <MLNStylable>)mapView error:(NSError * __nullable * __nullable)outError;
- (BOOL)removeFromStylable:(id<MLNStylable>)mapView error:(NSError *__nullable *__nullable)outError;
@end

View File

@@ -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<MLNDefaultStyle*>*) predefinedStyles;
+ (NSArray<MLNDefaultStyle *> *)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
<a href="https://www.mapbox.com/vector-tiles/mapbox-streets-v8/#overview">Mapbox Streets source</a>.
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.
<a href="https://www.mapbox.com/vector-tiles/mapbox-streets-v8/#overview">Mapbox Streets
source</a>. 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

View File

@@ -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;

View File

@@ -43,5 +43,5 @@ private:
std::vector<std::unique_ptr<LayerFactory>> coreFactories;
std::map<std::string, LayerFactory*> typeToFactory;
};
} // namespace mbgl
} // namespace mbgl

View File

@@ -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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#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<T> : MLNStyleValue<T>
@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<T> : MLNStyleFunction<T>
@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<T> : MLNStyleFunction<T>
@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<T> : MLNStyleFunction<T>
@end

View File

@@ -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 <mbgl/style/conversion/color_ramp_property_value.hpp>
#include <mbgl/style/conversion/property_value.hpp>
#include <mbgl/style/conversion/position.hpp>
#include <mbgl/style/conversion/property_value.hpp>
#include <mbgl/style/expression/dsl.hpp>
#import <mbgl/style/transition_options.hpp>
#import <mbgl/style/types.hpp>
#import "MLNConversion.h"
#import <mbgl/util/enum.hpp>
#include <mbgl/util/interpolate.hpp>
@@ -22,329 +22,323 @@
#include <memory>
#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<mbgl::style::expression::Expression> MLNClusterPropertyFromNSExpression(NSExpression *expression);
std::unique_ptr<mbgl::style::expression::Expression> MLNClusterPropertyFromNSExpression(
NSExpression *expression);
id MLNJSONObjectFromMBGLExpression(const mbgl::style::expression::Expression &mbglExpression);
template <typename MBGLType, typename ObjCType, typename MBGLElement = MBGLType, typename ObjCEnum = ObjCType>
template <typename MBGLType, typename ObjCType, typename MBGLElement = MBGLType,
typename ObjCEnum = ObjCType>
class MLNStyleValueTransformer {
public:
public:
/// Convert an mbgl property value into an mgl style value
NSExpression *toExpression(const mbgl::style::PropertyValue<MBGLType> &mbglValue) {
PropertyExpressionEvaluator evaluator;
return mbglValue.evaluate(evaluator);
}
/// Convert an mbgl property value into an mgl style value
NSExpression *toExpression(const mbgl::style::PropertyValue<MBGLType> &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 MBGLValue>
typename std::enable_if_t<!std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::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 MBGLValue>
typename std::enable_if_t<!std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::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<MBGLValue>(
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<MBGLValue>(
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 MBGLValue>
typename std::enable_if_t<std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::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::ColorRampPropertyValue>(
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 MBGLValue>
typename std::enable_if_t<std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::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 <typename MBGLEnum = MBGLType,
class = typename std::enable_if<!std::is_enum<MBGLEnum>::value>::type,
typename MLNEnum = ObjCEnum,
class = typename std::enable_if<!std::is_enum<MLNEnum>::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<float, 2> 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::ColorRampPropertyValue>(
mbgl::style::conversion::makeConvertible(jsonExpression), valueError);
if (!value) {
[NSException raise:NSInvalidArgumentException
format:@"Invalid property value: %@", @(valueError.message.c_str())];
return {};
}
template <typename MBGLEnum = MBGLType,
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
typename MLNEnum = ObjCEnum,
class = typename std::enable_if<std::is_enum<MLNEnum>::value>::type>
NSString* toRawStyleSpecValue(ObjCType rawValue, MBGLEnum &) {
MLNEnum mglEnum;
[rawValue getValue:&mglEnum];
return @(mbgl::Enum<MLNEnum>::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 <typename MBGLEnum = MBGLType,
class = typename std::enable_if<!std::is_enum<MBGLEnum>::value>::type,
typename MLNEnum = ObjCEnum,
class = typename std::enable_if<!std::is_enum<MLNEnum>::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<float, 2> mglValue = rawNSValue.mgl_offsetArrayValue;
return [NSArray arrayWithObjects:@(mglValue[0]), @(mglValue[1]), nil];
}
}
// noop pass-through plain NSObject-based items
return rawMLNValue;
}
template <typename MBGLEnum = MBGLType,
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
typename MLNEnum = ObjCEnum,
class = typename std::enable_if<std::is_enum<MLNEnum>::value>::type>
NSString *toRawStyleSpecValue(ObjCType rawValue, MBGLEnum &) {
MLNEnum mglEnum;
[rawValue getValue:&mglEnum];
return @(mbgl::Enum<MLNEnum>::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<float, 2> &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<float, 4> &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<MBGLElement> &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 <typename MBGLEnum = MBGLType,
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
typename MLNEnum = ObjCEnum,
class = typename std::enable_if<std::is_enum<MLNEnum>::value>::type>
void getMBGLValue(id rawValue, MBGLEnum &mbglValue) {
if ([rawValue isKindOfClass:[NSString class]]) {
mbglValue = *mbgl::Enum<MBGLEnum>::toEnum([(NSString *)rawValue UTF8String]);
} else {
MLNEnum mglEnum;
[(NSValue *)rawValue getValue:&mglEnum];
auto str = mbgl::Enum<MLNEnum>::toString(mglEnum);
mbglValue = *mbgl::Enum<MBGLEnum>::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<float, 2> &mbglStopValue) {
return [NSValue mgl_valueWithOffsetArray:mbglStopValue];
}
// Padding
static NSValue *toMLNRawStyleValue(const std::array<float, 4> &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<NSExpression *> *toMLNRawStyleValue(
const std::vector<MBGLElement> &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<float, 3> spherical = mbglStopValue.getSpherical();
MLNSphericalPosition position =
MLNSphericalPositionMake(spherical[0], spherical[1], spherical[2]);
return [NSValue valueWithMLNSphericalPosition:position];
}
// Enumerations
template <typename MBGLEnum = MBGLType, typename MLNEnum = ObjCEnum>
static NSString *toMLNRawStyleValue(const MBGLEnum &value) {
return @(mbgl::Enum<MBGLEnum>::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<MBGLType> &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<float, 2> &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<float, 4> &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<MBGLElement> &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 <typename MBGLEnum = MBGLType,
class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
typename MLNEnum = ObjCEnum,
class = typename std::enable_if<std::is_enum<MLNEnum>::value>::type>
void getMBGLValue(id rawValue, MBGLEnum &mbglValue) {
if ([rawValue isKindOfClass:[NSString class]]) {
mbglValue = *mbgl::Enum<MBGLEnum>::toEnum([(NSString *)rawValue UTF8String]);
} else {
MLNEnum mglEnum;
[(NSValue *)rawValue getValue:&mglEnum];
auto str = mbgl::Enum<MLNEnum>::toString(mglEnum);
mbglValue = *mbgl::Enum<MBGLEnum>::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<float, 2> &mbglStopValue) {
return [NSValue mgl_valueWithOffsetArray:mbglStopValue];
}
// Padding
static NSValue *toMLNRawStyleValue(const std::array<float, 4> &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<NSExpression*> *toMLNRawStyleValue(const std::vector<MBGLElement> &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<float, 3> spherical = mbglStopValue.getSpherical();
MLNSphericalPosition position = MLNSphericalPositionMake(spherical[0], spherical[1], spherical[2]);
return [NSValue valueWithMLNSphericalPosition:position];
}
// Enumerations
template <typename MBGLEnum = MBGLType, typename MLNEnum = ObjCEnum>
static NSString *toMLNRawStyleValue(const MBGLEnum &value) {
return @(mbgl::Enum<MBGLEnum>::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<MBGLType> &mbglValue) const {
return [NSExpression expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())];
}
};
};
};

View File

@@ -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 <MLNStylable>)stylable;
- (instancetype)initWithRawStyle:(mbgl::style::Style *)rawStyle stylable:(id<MLNStylable>)stylable;
@property (nonatomic, readonly, weak) id <MLNStylable> stylable;
@property (nonatomic, readonly, weak) id<MLNStylable> stylable;
@property (nonatomic, readonly) mbgl::style::Style *rawStyle;
- (nullable NSArray<MLNAttributionInfo *> *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MLNColor *)linkColor;
@property (nonatomic, readonly, strong) NSMutableDictionary<NSString *, MLNCustomStyleLayer *> *customLayers;
- (void)setStyleClasses:(NSArray<NSString *> *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration;
- (nullable NSArray<MLNAttributionInfo *> *)attributionInfosWithFontSize:(CGFloat)fontSize
linkColor:
(nullable MLNColor *)linkColor;
@property (nonatomic, readonly, strong)
NSMutableDictionary<NSString *, MLNCustomStyleLayer *> *customLayers;
- (void)setStyleClasses:(NSArray<NSString *> *)appliedClasses
transitionDuration:(NSTimeInterval)transitionDuration;
@end

View File

@@ -1,29 +1,29 @@
#import <Foundation/Foundation.h>
#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

View File

@@ -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

View File

@@ -1,7 +1,7 @@
#import <Foundation/Foundation.h>
#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<MLNDefaultStyle*>* defaultStyles;
/**

View File

@@ -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
<a href="http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification">Tile Map Service Specification</a>.
*/
MLNTileCoordinateSystemTMS
This tile coordinate system is used by tile servers that conform to the
<a href="http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification">Tile Map Service
Specification</a>.
*/
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
<a href="https://www.mapbox.com/studio/tilesets/">Mapbox Studio’s Tilesets editor</a>.

View File

@@ -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<MLNAttributionInfo *> *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MLNColor *)linkColor;
- (NSArray<MLNAttributionInfo *> *)attributionInfosWithFontSize:(CGFloat)fontSize
linkColor:(nullable MLNColor *)linkColor;
@end
MLN_EXPORT
mbgl::Tileset MLNTileSetFromTileURLTemplates(NSArray<NSString *> *tileURLTemplates, NSDictionary<MLNTileSourceOption, id> * _Nullable options);
mbgl::Tileset MLNTileSetFromTileURLTemplates(
NSArray<NSString *> *tileURLTemplates,
NSDictionary<MLNTileSourceOption, id> *_Nullable options);
NS_ASSUME_NONNULL_END

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#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

View File

@@ -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<mbgl::Value> &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<mbgl::Value> &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<std::string, mbgl::Value> &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<std::string, mbgl::Value> &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;
}
};

View File

@@ -1,7 +1,7 @@
#import <Foundation/Foundation.h>
#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
<a href="https://maplibre.org/maplibre-style-spec/#layer-filter">`filter`</a>
property in the style JSON.
See the “<a href="../predicates-and-expressions.html">Predicates and Expressions</a>”
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;

View File

@@ -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
<a href="https://www.mapbox.com/studio/">Mapbox Studio</a>. For
@@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
(<var>extent</var>&nbsp;×&nbsp;2)&nbsp;−&nbsp;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
<a href="https://www.mapbox.com/vector-tiles/mapbox-streets/">Mapbox Streets</a>,
<a href="https://www.mapbox.com/vector-tiles/mapbox-terrain/">Mapbox Terrain</a>,
@@ -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<NSString *> *)tileURLTemplates options:(nullable NSDictionary<MLNTileSourceOption, id> *)options NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithIdentifier:(NSString *)identifier
tileURLTemplates:(NSArray<NSString *> *)tileURLTemplates
options:(nullable NSDictionary<MLNTileSourceOption, id> *)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<id <MLNFeature>> *)featuresInSourceLayersWithIdentifiers:(NSSet<NSString *> *)sourceLayerIdentifiers predicate:(nullable NSPredicate *)predicate NS_SWIFT_NAME(features(sourceLayerIdentifiers:predicate:));
- (NSArray<id<MLNFeature>> *)featuresInSourceLayersWithIdentifiers:
(NSSet<NSString *> *)sourceLayerIdentifiers
predicate:(nullable NSPredicate *)predicate
NS_SWIFT_NAME(features(sourceLayerIdentifiers:predicate:));
@end

View File

@@ -9,7 +9,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSSet<NSString *> *)mapboxStreetsLanguages;
+ (nullable NSString *)preferredMapboxStreetsLanguage;
+ (nullable NSString *)preferredMapboxStreetsLanguageForPreferences:(NSArray<NSString *> *)preferencesArray;
+ (nullable NSString *)preferredMapboxStreetsLanguageForPreferences:
(NSArray<NSString *> *)preferencesArray;
@end

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import <mbgl/util/feature.hpp>
@@ -7,7 +7,8 @@
- (std::vector<mbgl::Value>)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;
/**

View File

@@ -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;

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import <mbgl/util/feature.hpp>
@@ -9,7 +9,8 @@
- (CLLocationCoordinate2D)decodeMLNCoordinateForKey:(NSString *)key;
- (void)mgl_encodeLocationCoordinates2D:(std::vector<CLLocationCoordinate2D>)coordinates forKey:(NSString *)key;
- (void)mgl_encodeLocationCoordinates2D:(std::vector<CLLocationCoordinate2D>)coordinates
forKey:(NSString *)key;
- (std::vector<CLLocationCoordinate2D>)mgl_decodeLocationCoordinates2DForKey:(NSString *)key;

View File

@@ -1,11 +1,10 @@
#import <Foundation/Foundation.h>
#import "MLNFoundation.h"
#include <mbgl/util/chrono.hpp>
#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);

View File

@@ -1,4 +1,7 @@
#import <Foundation/Foundation.h>
#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])

View File

@@ -1,8 +1,8 @@
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#import <Cocoa/Cocoa.h>
#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
<a href="https://maplibre.org/maplibre-style-spec/expressions/#interpolate"><code>interpolate</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#interpolate"><code>interpolate</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/expressions/#interpolate"><code>interpolate</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#interpolate"><code>interpolate</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/expressions/#interpolate"><code>interpolate</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#interpolate"><code>interpolate</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/expressions/#heatmap-density"><code>heatmap-density</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#heatmap-density"><code>heatmap-density</code></a>
expression operator in the MapLibre Style Spec.
*/
@property (class, nonatomic, readonly) NSExpression *heatmapDensityVariableExpression;
/**
`NSExpression` variable that corresponds to the
<a href="https://maplibre.org/maplibre-style-spec/expressions/#line-progress"><code>line-progress</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#line-progress"><code>line-progress</code></a>
expression operator in the MapLibre Style Spec.
*/
@property (class, nonatomic, readonly) NSExpression *lineProgressVariableExpression;
/**
`NSExpression` variable that corresponds to the
<a href="https://maplibre.org/maplibre-style-spec/expressions/#geometry-type"><code>geometry-type</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#geometry-type"><code>geometry-type</code></a>
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
<a href="https://maplibre.org/maplibre-style-spec/expressions/#properties"><code>properties</code></a>
<a
href="https://maplibre.org/maplibre-style-spec/expressions/#properties"><code>properties</code></a>
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<NSExpression *, NSExpression *> *)matchedExpressions defaultExpression:(nonnull NSExpression *)defaultExpression NS_SWIFT_NAME(init(forMLNMatchingKey:in:default:));
+ (instancetype)mgl_expressionForMatchingExpression:(nonnull NSExpression *)inputExpression
inDictionary:
(nonnull NSDictionary<NSExpression *, NSExpression *> *)
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<NSExpression *> *)attributedExpressions NS_SWIFT_NAME(init(forAttributedExpressions:));
+ (instancetype)mgl_expressionForAttributedExpressions:
(nonnull NSArray<NSExpression *> *)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
<a href="https://www.mapbox.com/vector-tiles/mapbox-streets-v8/#overview">Mapbox Streets source</a>.
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.
<a href="https://www.mapbox.com/vector-tiles/mapbox-streets-v8/#overview">Mapbox Streets
source</a>. 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`.

View File

@@ -1,8 +1,8 @@
#import <Foundation/Foundation.h>
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#import <Cocoa/Cocoa.h>
#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<NSNumber *, id> *)stops;
- (id)mgl_interpolateWithCurveType:(NSString *)curveType
parameters:(NSArray *)parameters
stops:(NSDictionary<NSNumber *, id> *)stops;
- (id)mgl_stepWithMinimum:(id)minimum stops:(NSDictionary<NSNumber *, id> *)stops;
@property (nonatomic, readonly) id mgl_jsonExpressionObject;
@@ -74,7 +77,6 @@ NS_ASSUME_NONNULL_BEGIN
- (NSExpression *)mgl_expressionWithContext:(NSDictionary<NSString *, NSExpression *> *)context;
- (id)mgl_has:(id)element;
@end

View File

@@ -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.
*/

View File

@@ -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.
*/

View File

@@ -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<Impl*>(info)->runTask();
}
static void perform(void* info) { reinterpret_cast<Impl*>(info)->runTask(); }
std::function<void()> task;
std::atomic_flag queued = ATOMIC_FLAG_INIT;
@@ -58,8 +46,7 @@ private:
};
AsyncTask::AsyncTask(std::function<void()>&& fn)
: impl(std::make_unique<Impl>(std::move(fn))) {
}
: impl(std::make_unique<Impl>(std::move(fn))) {}
AsyncTask::~AsyncTask() = default;

View File

@@ -3,17 +3,17 @@
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE
#include <OpenGLES/ES3/gl.h>
#include <OpenGLES/ES3/glext.h>
#include <OpenGLES/ES3/gl.h>
#include <OpenGLES/ES3/glext.h>
#elif TARGET_OS_SIMULATOR
#include <OpenGLES/ES3/gl.h>
#include <OpenGLES/ES3/glext.h>
#include <OpenGLES/ES3/gl.h>
#include <OpenGLES/ES3/glext.h>
#elif TARGET_OS_MAC
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#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

View File

@@ -20,7 +20,7 @@ RunLoop* RunLoop::Get() {
}
RunLoop::RunLoop(Type)
: impl(std::make_unique<Impl>()) {
: impl(std::make_unique<Impl>()) {
assert(!Scheduler::GetCurrent());
Scheduler::SetCurrent(this);
impl->async = std::make_unique<AsyncTask>(std::bind(&RunLoop::process, this));

View File

@@ -18,14 +18,9 @@ public:
Impl(Duration timeout, Duration repeat, std::function<void()>&& 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<Impl*>(info)->task();
}
static void perform(CFRunLoopTimerRef, void* info) { reinterpret_cast<Impl*>(info)->task(); }
std::function<void()> task;

View File

@@ -1,8 +1,7 @@
#import <Mapbox.h>
#import <XCTest/XCTest.h>
#define MLNConstantExpression(constant) \
[NSExpression expressionForConstantValue:constant]
#define MLNConstantExpression(constant) [NSExpression expressionForConstantValue:constant]
@interface MLNStyleLayerTests : XCTestCase <MLNMapViewDelegate>

View File

@@ -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; \
} \
}

View File

@@ -1,4 +1,3 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

Some files were not shown because too many files have changed in this diff Show More