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

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

View File

@@ -8,7 +8,8 @@ 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. */
@@ -22,10 +23,10 @@ FOUNDATION_EXTERN MLN_EXPORT MLNAttributedExpressionKey const MLNFontColorAttrib
```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)
```
@@ -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"

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,8 +2,7 @@
#import <MetalKit/MetalKit.h>
typedef struct
{
typedef struct {
MTKView *mtkView;
id<MTLDevice> device;
MTLRenderPassDescriptor *renderPassDescriptor;
@@ -12,8 +11,7 @@ typedef struct
#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

@@ -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
@@ -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
@@ -103,7 +106,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 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
@@ -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
@@ -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

@@ -49,7 +49,8 @@ public:
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).");
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};
@@ -64,7 +65,8 @@ public:
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) {
[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;
@@ -128,7 +130,9 @@ public:
id object = holder.value;
if ([object isKindOfClass:[NSDictionary class]]) {
NSError* serializationError;
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:&serializationError];
NSData* data = [NSJSONSerialization dataWithJSONObject:object
options:0
error:&serializationError];
if (serializationError) {
error = {std::string(serializationError.localizedDescription.UTF8String)};
return {};
@@ -136,7 +140,8 @@ public:
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) };
error = {std::string(
[NSString stringWithFormat:@"%@ is not a GeoJSON object.", object].UTF8String)};
return {};
}
}
@@ -155,14 +160,10 @@ private:
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

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

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

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "MLNFoundation.h"

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

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,14 +13,16 @@ 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
@@ -39,19 +41,23 @@ MLNShape* MLNShapeFromGeoJSON(const mapbox::geojson::geojson &geojson);
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]]]; \
NSSet<Class> *identifierClasses = \
[NSSet setWithArray:@[ [NSString class], [NSNumber class] ]]; \
identifier = [decoder decodeObjectOfClasses:identifierClasses forKey:@"identifier"]; \
_attributes = [decoder decodeObjectOfClass:[NSDictionary class] forKey:@"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

@@ -16,4 +16,3 @@ void MLNInitializeRunLoop();
__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"
@@ -36,7 +36,8 @@ typedef struct MLNMatrix4 {
Creates a new `MLNCoordinateSpan` from the given latitudinal and longitudinal
deltas.
*/
NS_INLINE MLNCoordinateSpan MLNCoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta) {
NS_INLINE MLNCoordinateSpan MLNCoordinateSpanMake(CLLocationDegrees latitudeDelta,
CLLocationDegrees longitudeDelta) {
MLNCoordinateSpan span;
span.latitudeDelta = latitudeDelta;
span.longitudeDelta = longitudeDelta;
@@ -58,7 +59,8 @@ NS_INLINE MLNMapPoint MLNMapPointMake(CGFloat x, CGFloat y, CGFloat zoomLevel) {
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) {
NS_INLINE BOOL MLNCoordinateSpanEqualToCoordinateSpan(MLNCoordinateSpan span1,
MLNCoordinateSpan span2) {
return (span1.latitudeDelta == span2.latitudeDelta &&
span1.longitudeDelta == span2.longitudeDelta);
}
@@ -91,12 +93,12 @@ typedef struct MLNCoordinateQuad {
CLLocationCoordinate2D topRight;
} MLNCoordinateQuad;
/**
Creates a new `MLNCoordinateBounds` structure from the given southwest and
northeast coordinates.
*/
NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsMake(CLLocationCoordinate2D sw, CLLocationCoordinate2D ne) {
NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsMake(CLLocationCoordinate2D sw,
CLLocationCoordinate2D ne) {
MLNCoordinateBounds bounds;
bounds.sw = sw;
bounds.ne = ne;
@@ -107,7 +109,10 @@ NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsMake(CLLocationCoordinate2D sw,
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) {
NS_INLINE MLNCoordinateQuad MLNCoordinateQuadMake(CLLocationCoordinate2D topLeft,
CLLocationCoordinate2D bottomLeft,
CLLocationCoordinate2D bottomRight,
CLLocationCoordinate2D topRight) {
MLNCoordinateQuad quad;
quad.topLeft = topLeft;
quad.bottomLeft = bottomLeft;
@@ -131,17 +136,17 @@ NS_INLINE MLNCoordinateQuad MLNCoordinateQuadFromCoordinateBounds(MLNCoordinateB
}
/** 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 &&
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);
}
@@ -154,9 +159,9 @@ NS_INLINE BOOL MLNCoordinateBoundsIntersectsCoordinateBounds(MLNCoordinateBounds
`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 &&
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);
}
@@ -171,7 +176,8 @@ NS_INLINE MLNCoordinateSpan MLNCoordinateBoundsGetCoordinateSpan(MLNCoordinateBo
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) {
NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsOffset(MLNCoordinateBounds bounds,
MLNCoordinateSpan offset) {
MLNCoordinateBounds offsetBounds = bounds;
offsetBounds.sw.latitude += offset.latitudeDelta;
offsetBounds.sw.longitude += offset.longitudeDelta;
@@ -193,14 +199,14 @@ NS_INLINE BOOL MLNCoordinateBoundsIsEmpty(MLNCoordinateBounds bounds) {
/** 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}",
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,
@@ -213,13 +219,11 @@ NS_INLINE CGFloat MLNRadiansFromDegrees(CLLocationDegrees degrees) {
}
/** 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.
@@ -228,7 +232,10 @@ FOUNDATION_EXTERN MLN_EXPORT MLNMapPoint MLNMapPointForCoordinate(CLLocationCoor
@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.
@@ -237,6 +244,9 @@ FOUNDATION_EXTERN MLN_EXPORT CLLocationDistance MLNAltitudeForZoomLevel(double z
@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

@@ -22,7 +22,8 @@ typedef struct MLNRadianCoordinate2D {
/**
Creates a new `MLNRadianCoordinate2D` from the given latitudinal and longitudinal.
*/
NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinate2DMake(MLNLocationRadians latitude, MLNLocationRadians longitude) {
NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinate2DMake(MLNLocationRadians latitude,
MLNLocationRadians longitude) {
MLNRadianCoordinate2D radianCoordinate;
radianCoordinate.latitude = latitude;
radianCoordinate.longitude = longitude;
@@ -34,17 +35,14 @@ 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);
@@ -66,7 +64,8 @@ NS_INLINE MLNCoordinateBounds MLNCoordinateBoundsFromLatLngBounds(mbgl::LatLngBo
MLNLocationCoordinate2DFromLatLng(latLngBounds.northeast()));
}
NS_INLINE mbgl::LatLngBounds MLNLatLngBoundsFromCoordinateBounds(MLNCoordinateBounds coordinateBounds) {
NS_INLINE mbgl::LatLngBounds MLNLatLngBoundsFromCoordinateBounds(
MLNCoordinateBounds coordinateBounds) {
return mbgl::LatLngBounds::hull(MLNLatLngFromLocationCoordinate2D(coordinateBounds.sw),
MLNLatLngFromLocationCoordinate2D(coordinateBounds.ne));
}
@@ -79,10 +78,8 @@ NS_INLINE std::array<mbgl::LatLng, 4> MLNLatLngArrayFromCoordinateQuad(MLNCoordi
}
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,10 +87,8 @@ 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
@@ -114,14 +109,13 @@ NS_INLINE MLNEdgeInsets NSEdgeInsetsFromMLNEdgeInsets(const mbgl::EdgeInsets& in
/// 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,
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) {
NS_INLINE MLNRadianCoordinate2D
MLNRadianCoordinateFromLocationCoordinate(CLLocationCoordinate2D locationCoordinate) {
return MLNRadianCoordinate2DMake(MLNRadiansFromDegrees(locationCoordinate.latitude),
MLNRadiansFromDegrees(locationCoordinate.longitude));
}
@@ -129,12 +123,14 @@ NS_INLINE MLNRadianCoordinate2D MLNRadianCoordinateFromLocationCoordinate(CLLoca
/**
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
@@ -38,8 +38,8 @@ 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
@@ -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
@@ -91,7 +97,8 @@ 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;

View File

@@ -6,7 +6,7 @@ namespace mbgl {
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
@@ -63,9 +63,9 @@ NS_ASSUME_NONNULL_BEGIN
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
@@ -98,7 +98,8 @@ NS_ASSUME_NONNULL_BEGIN
@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
@@ -198,8 +199,7 @@ NS_ASSUME_NONNULL_BEGIN
@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.
@@ -218,8 +218,7 @@ NS_ASSUME_NONNULL_BEGIN
@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.

View File

@@ -58,7 +58,8 @@ typedef NS_ENUM(NSInteger, MLNLoggingLevel) {
@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

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,15 +20,20 @@ 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(...)
#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
@@ -48,20 +52,25 @@ NS_INLINE NSString *MLNStringFromNSEdgeInsets(NSEdgeInsets insets) {
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__]; \
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"

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
@@ -71,7 +71,9 @@ MLN_EXPORT
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
@@ -157,7 +159,6 @@ MLN_EXPORT
*/
- (CLLocationCoordinate2D)coordinateForPoint:(NSPoint)point;
/**
The image of the map’s content.
*/
@@ -173,7 +174,8 @@ MLN_EXPORT
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
@@ -201,10 +203,11 @@ typedef void (^MLNMapSnapshotCompletionHandler)(MLNMapSnapshot* _Nullable snapsh
### Example
```swift
let camera = MLNMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0)
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 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
@@ -252,7 +255,8 @@ MLN_EXPORT
@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
@@ -266,7 +270,8 @@ 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.

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "MLNFoundation.h"
#import "MLNShape.h"
@@ -72,7 +72,9 @@ 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.
@@ -112,7 +114,8 @@ 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
@@ -142,7 +145,9 @@ 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.

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.

View File

@@ -1,12 +1,13 @@
#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

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
@@ -109,8 +109,8 @@ typedef struct __attribute__((objc_boxable)) MLNOfflinePackProgress {
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
@@ -151,7 +151,8 @@ MLN_EXPORT
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

@@ -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
@@ -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.
@@ -246,7 +249,8 @@ MLN_EXPORT
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.
@@ -263,7 +267,8 @@ MLN_EXPORT
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,7 +337,8 @@ 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
@@ -346,7 +354,8 @@ MLN_EXPORT
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
@@ -406,7 +415,8 @@ MLN_EXPORT
@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
@@ -455,7 +465,8 @@ MLN_EXPORT
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"

View File

@@ -1,5 +1,5 @@
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <Foundation/Foundation.h>
#import "MLNFoundation.h"
#import "MLNShape.h"

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

@@ -34,7 +34,9 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNTileSourceOption MLNTileSourceOptionDEMEnc
`-[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;
}
}
} // 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,14 +28,15 @@
#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;
@@ -52,7 +53,6 @@ typedef NS_ENUM(NSInteger, NetworkStatus) {
typedef void (^NetworkReachable)(MLNReachability *reachability);
typedef void (^NetworkUnreachable)(MLNReachability *reachability);
@interface MLNReachability : NSObject
@property (nonatomic, copy) NetworkReachable reachableBlock;
@@ -60,7 +60,6 @@ typedef void (^NetworkUnreachable)(MLNReachability * reachability);
@property (nonatomic, assign) BOOL reachableOnWWAN;
+ (instancetype)reachabilityWithHostname:(NSString *)hostname;
// This is identical to the function above, but is here to maintain
// compatibility with Apples original code. (see .m)

View File

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

View File

@@ -1,24 +1,20 @@
#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
{
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_) {
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];
});
asyncInvalidate.emplace([&]() { [nativeView setNeedsRerender]; });
}
}
@@ -55,9 +51,7 @@ public:
renderer->render(updateParameters_);
}
mbgl::Renderer* getRenderer() {
return renderer.get();
}
mbgl::Renderer* getRenderer() { return renderer.get(); }
void reduceMemoryUse() {
if (!renderer) return;

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

@@ -19,8 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
]
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!)
```
@@ -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
@@ -20,7 +20,8 @@ typedef NSString *MLNShapeSourceOption NS_STRING_ENUM;
`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
@@ -68,7 +69,8 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionClus
```
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
@@ -82,20 +84,23 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionClus
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;
@@ -106,7 +111,8 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionMini
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;
@@ -129,7 +135,8 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionBuff
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;
@@ -137,11 +144,12 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNShapeSourceOption MLNShapeSourceOptionSimp
/**
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`.
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;
@@ -215,7 +223,10 @@ MLN_EXPORT
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
@@ -248,7 +259,10 @@ MLN_EXPORT
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
@@ -275,7 +289,9 @@ 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
@@ -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
@@ -365,20 +383,24 @@ MLN_EXPORT
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.
@@ -391,7 +413,8 @@ 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,6 +1,6 @@
#include <mbgl/util/immutable.hpp>
#import "MLNFoundation.h"
#import "MLNShapeSource.h"
#include <mbgl/util/immutable.hpp>
NS_ASSUME_NONNULL_BEGIN
@@ -8,10 +8,11 @@ namespace mbgl {
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)

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,7 +2,6 @@
#include <memory>
NS_ASSUME_NONNULL_BEGIN
@protocol MLNStylable;
@@ -11,7 +10,7 @@ namespace mbgl {
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
@@ -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,

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;
@@ -158,7 +158,6 @@ MLN_EXPORT
*/
- (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

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

@@ -26,13 +26,13 @@ struct LayerWrapper {
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."]; \
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);

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."))),
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.")))
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>
@@ -32,32 +32,35 @@ namespace mbgl {
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.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) } };
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:
/// Convert an mbgl property value into an mgl style value
NSExpression *toExpression(const mbgl::style::PropertyValue<MBGLType> &mbglValue) {
PropertyExpressionEvaluator evaluator;
@@ -69,7 +72,8 @@ public:
if (mbglValue.isUndefined()) {
return nil;
}
return [NSExpression expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())];
return [NSExpression
expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())];
}
/**
@@ -77,7 +81,8 @@ public:
*/
template <typename MBGLValue>
typename std::enable_if_t<!std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::value,
MBGLValue> toPropertyValue(NSExpression *expression, bool allowDataExpressions) {
MBGLValue>
toPropertyValue(NSExpression *expression, bool allowDataExpressions) {
if (!expression) {
return {};
}
@@ -97,7 +102,8 @@ public:
mbgl::style::conversion::Error valueError;
auto value = mbgl::style::conversion::convert<MBGLValue>(
mbgl::style::conversion::makeConvertible(jsonExpression), valueError, allowDataExpressions, false);
mbgl::style::conversion::makeConvertible(jsonExpression), valueError, allowDataExpressions,
false);
if (!value) {
[NSException raise:NSInvalidArgumentException
format:@"Invalid property value: %@", @(valueError.message.c_str())];
@@ -112,7 +118,8 @@ public:
*/
template <typename MBGLValue>
typename std::enable_if_t<std::is_same<MBGLValue, mbgl::style::ColorRampPropertyValue>::value,
MBGLValue> toPropertyValue(NSExpression *expression) {
MBGLValue>
toPropertyValue(NSExpression *expression) {
if (!expression) {
return {};
}
@@ -132,11 +139,11 @@ public:
}
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.
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,
@@ -170,19 +177,13 @@ private: // Private utilities for converting from mgl to mbgl values
}
// Bool
void getMBGLValue(NSNumber *rawValue, bool &mbglValue) {
mbglValue = !!rawValue.boolValue;
}
void getMBGLValue(NSNumber *rawValue, bool &mbglValue) { mbglValue = !!rawValue.boolValue; }
// Float
void getMBGLValue(NSNumber *rawValue, float &mbglValue) {
mbglValue = rawValue.floatValue;
}
void getMBGLValue(NSNumber *rawValue, float &mbglValue) { mbglValue = rawValue.floatValue; }
// String
void getMBGLValue(NSString *rawValue, std::string &mbglValue) {
mbglValue = rawValue.UTF8String;
}
void getMBGLValue(NSString *rawValue, std::string &mbglValue) { mbglValue = rawValue.UTF8String; }
// Formatted
void getMBGLValue(NSString *rawValue, mbgl::style::expression::Formatted &mbglValue) {
@@ -215,9 +216,7 @@ private: // Private utilities for converting from mgl to mbgl values
}
// Color
void getMBGLValue(MLNColor *rawValue, mbgl::Color &mbglValue) {
mbglValue = rawValue.mgl_color;
}
void getMBGLValue(MLNColor *rawValue, mbgl::Color &mbglValue) { mbglValue = rawValue.mgl_color; }
// Image
void getMBGLValue(NSString *rawValue, mbgl::style::expression::Image &mbglValue) {
@@ -229,7 +228,8 @@ private: // Private utilities for converting from mgl to mbgl values
mbglValue.reserve(rawValue.count);
for (id obj in rawValue) {
id constantObject = obj;
if ([obj isKindOfClass:[NSExpression class]] && [obj expressionType] == NSConstantValueExpressionType) {
if ([obj isKindOfClass:[NSExpression class]] &&
[obj expressionType] == NSConstantValueExpressionType) {
constantObject = [constantObject constantValue];
}
MBGLElement mbglElement;
@@ -261,21 +261,14 @@ private: // Private utilities for converting from mgl to mbgl values
}
private: // Private utilities for converting from mbgl to mgl values
// Bool
static NSNumber *toMLNRawStyleValue(const bool mbglStopValue) {
return @(mbglStopValue);
}
static NSNumber *toMLNRawStyleValue(const bool mbglStopValue) { return @(mbglStopValue); }
// Float
static NSNumber *toMLNRawStyleValue(const float mbglStopValue) {
return @(mbglStopValue);
}
static NSNumber *toMLNRawStyleValue(const float mbglStopValue) { return @(mbglStopValue); }
// Integer
static NSNumber *toMLNRawStyleValue(const int64_t mbglStopValue) {
return @(mbglStopValue);
}
static NSNumber *toMLNRawStyleValue(const int64_t mbglStopValue) { return @(mbglStopValue); }
// String
static NSString *toMLNRawStyleValue(const std::string &mbglStopValue) {
@@ -308,7 +301,8 @@ private: // Private utilities for converting from mbgl to mgl values
}
// Array
static NSArray<NSExpression*> *toMLNRawStyleValue(const std::vector<MBGLElement> &mbglStopValue) {
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)]];
@@ -318,7 +312,8 @@ private: // Private utilities for converting from mbgl to mgl values
static NSValue *toMLNRawStyleValue(const mbgl::style::Position &mbglStopValue) {
std::array<float, 3> spherical = mbglStopValue.getSpherical();
MLNSphericalPosition position = MLNSphericalPositionMake(spherical[0], spherical[1], spherical[2]);
MLNSphericalPosition position =
MLNSphericalPositionMake(spherical[0], spherical[1], spherical[2]);
return [NSValue valueWithMLNSphericalPosition:position];
}
@@ -331,9 +326,7 @@ private: // Private utilities for converting from mbgl to mgl values
/// 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 mbgl::style::Undefined) const { return nil; }
NSExpression *operator()(const MBGLType &value) const {
id constantValue = toMLNRawStyleValue(value);
@@ -344,7 +337,8 @@ private: // Private utilities for converting from mbgl to mgl values
}
NSExpression *operator()(const mbgl::style::PropertyExpression<MBGLType> &mbglValue) const {
return [NSExpression expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())];
return [NSExpression
expressionWithMLNJSONObject:MLNJSONObjectFromMBGLExpression(mbglValue.getExpression())];
}
};
};

View File

@@ -1,7 +1,7 @@
#import "MLNStyle.h"
#import "MLNStyleLayer.h"
#import "MLNFillStyleLayer.h"
#import "MLNStyleLayer.h"
NS_ASSUME_NONNULL_BEGIN
@@ -9,7 +9,7 @@ namespace mbgl {
namespace style {
class Style;
}
}
} // namespace mbgl
@class MLNAttributionInfo;
@class MLNMapView;
@@ -24,9 +24,13 @@ namespace mbgl {
@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,8 +1,8 @@
#import <Foundation/Foundation.h>
#import "MLNFoundation.h"
#import "MLNOfflineRegion.h"
#import "MLNGeometry.h"
#import "MLNOfflineRegion.h"
NS_ASSUME_NONNULL_BEGIN
@@ -19,8 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
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!)
```
@@ -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

View File

@@ -136,7 +136,8 @@ typedef NS_ENUM(NSUInteger, MLNTileCoordinateSystem) {
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>.
<a href="http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification">Tile Map Service
Specification</a>.
*/
MLNTileCoordinateSystemTMS
};
@@ -148,12 +149,14 @@ 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).
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/).
Raster tiles generated with the [Mapzen Terrarium encoding
formula](https://aws.amazon.com/public-datasets/terrain/).
*/
MLNDEMEncodingTerrarium
};

View File

@@ -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"
@@ -104,7 +104,8 @@ typedef struct __attribute__((objc_boxable)) MLNTransition {
} 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];
}
/**

View File

@@ -7,29 +7,17 @@
*/
class ValueEvaluator {
public:
id operator()(const mbgl::NullValue &) const {
return [NSNull null];
}
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()];

View File

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

@@ -44,11 +44,12 @@ 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)
@@ -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
@@ -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

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

@@ -17,28 +17,34 @@ 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,12 +102,14 @@ 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
@@ -110,7 +121,10 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
@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
@@ -128,7 +142,10 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
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,
@@ -145,7 +162,12 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
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,
@@ -155,7 +177,12 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
@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
@@ -163,7 +190,9 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
@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
@@ -175,7 +204,8 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
@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
@@ -219,10 +249,10 @@ FOUNDATION_EXTERN MLN_EXPORT const MLNExpressionInterpolationMode MLNExpressionI
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

View File

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

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

@@ -42,8 +42,10 @@ 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 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;
@@ -83,7 +85,10 @@ 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 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;
@@ -131,7 +136,8 @@ 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 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;
@@ -168,11 +174,17 @@ void (* const glViewport)(GLint, GLint, GLsizei, GLsizei) = ::glViewport;
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 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;
@@ -189,8 +201,10 @@ void (* const glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *)
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 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;
@@ -203,8 +217,12 @@ 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 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;
@@ -267,12 +285,12 @@ void (* const glProgramBinary)(GLuint, GLenum, const GLvoid *, GLsizei) = ::glPr
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 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;
} // namespace platform
} // namespace mbgl

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

@@ -18,7 +18,8 @@
#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"]; \
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__); \

View File

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

View File

@@ -5,4 +5,3 @@
@property (strong, nonatomic) UIWindow *window;
@end

View File

@@ -1,15 +1,15 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNTestUtility.h"
#define MLNTestFail(myself, ...) \
_XCTPrimitiveFail(myself, __VA_ARGS__)
#define MLNTestFail(myself, ...) _XCTPrimitiveFail(myself, __VA_ARGS__)
#define MLNTestAssert(myself, expression, ...) \
_XCTPrimitiveAssertTrue(myself, expression, @ #expression, __VA_ARGS__)
#define MLNTestAssertEqualWithAccuracy(myself, expression1, expression2, accuracy, ...) \
_XCTPrimitiveAssertEqualWithAccuracy(myself, expression1, @#expression1, expression2, @#expression2, accuracy, @#accuracy, __VA_ARGS__)
_XCTPrimitiveAssertEqualWithAccuracy(myself, expression1, @ #expression1, expression2, \
@ #expression2, accuracy, @ #accuracy, __VA_ARGS__)
#define MLNTestAssertNil(myself, expression, ...) \
_XCTPrimitiveAssertNil(myself, expression, @ #expression, __VA_ARGS__)
@@ -20,7 +20,8 @@ _XCTPrimitiveFail(myself, __VA_ARGS__)
({ \
if (!(expression)) { \
NSString *message = [NSString stringWithFormat:format, ##__VA_ARGS__]; \
printf("warning: Test Case '%s' at line %d: '%s' %s\n", __PRETTY_FUNCTION__, __LINE__, #expression, message.UTF8String); \
printf("warning: Test Case '%s' at line %d: '%s' %s\n", __PRETTY_FUNCTION__, __LINE__, \
#expression, message.UTF8String); \
} \
})

View File

@@ -6,13 +6,17 @@
@property (nonatomic) MLNStyle *style;
@property (nonatomic) XCTestExpectation *styleLoadingExpectation;
@property (nonatomic) XCTestExpectation *renderFinishedExpectation;
@property (nonatomic) MLNAnnotationView * (^viewForAnnotation)(MLNMapView *mapView, id<MLNAnnotation> annotation);
@property (nonatomic) MLNAnnotationView * (^viewForAnnotation)
(MLNMapView *mapView, id<MLNAnnotation> annotation);
@property (nonatomic) void (^regionWillChange)(MLNMapView *mapView, BOOL animated);
@property (nonatomic) void (^regionIsChanging)(MLNMapView *mapView);
@property (nonatomic) void (^regionDidChange)(MLNMapView *mapView, MLNCameraChangeReason reason, BOOL animated);
@property (nonatomic) void (^regionDidChange)
(MLNMapView *mapView, MLNCameraChangeReason reason, BOOL animated);
@property (nonatomic) CGPoint (^mapViewUserLocationAnchorPoint)(MLNMapView *mapView);
@property (nonatomic) BOOL (^mapViewAnnotationCanShowCalloutForAnnotation)(MLNMapView *mapView, id<MLNAnnotation> annotation);
@property (nonatomic) id<MLNCalloutView> (^mapViewCalloutViewForAnnotation)(MLNMapView *mapView, id<MLNAnnotation> annotation);
@property (nonatomic) BOOL (^mapViewAnnotationCanShowCalloutForAnnotation)
(MLNMapView *mapView, id<MLNAnnotation> annotation);
@property (nonatomic) id<MLNCalloutView> (^mapViewCalloutViewForAnnotation)
(MLNMapView *mapView, id<MLNAnnotation> annotation);
// Utility methods
- (void)waitForMapViewToFinishLoadingStyleWithTimeout:(NSTimeInterval)timeout;

View File

@@ -1,5 +1,5 @@
#import <XCTest/XCTest.h>
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
#import "MLNTestUtility.h"
@interface MLNTestLocationManager : NSObject <MLNLocationManager>

View File

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

View File

@@ -1,5 +1,5 @@
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <UIKit/UIKit.h>
@interface MBXBenchViewController : UIViewController

View File

@@ -23,4 +23,4 @@ const std::vector<Location> locations = {
};
}
}
} // namespace mbgl

View File

@@ -1,7 +1,7 @@
#pragma once
#include <vector>
#include <string>
#include <vector>
namespace mbgl {
namespace bench {
@@ -16,5 +16,5 @@ struct Location {
extern const std::vector<Location> locations;
}
}
} // namespace bench
} // namespace mbgl

View File

@@ -8,7 +8,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface MLNAnnotationContainerView : UIView
+ (instancetype)annotationContainerViewWithAnnotationContainerView:(MLNAnnotationContainerView *)annotationContainerView;
+ (instancetype)annotationContainerViewWithAnnotationContainerView:
(MLNAnnotationContainerView *)annotationContainerView;
- (void)addSubviews:(NSArray<MLNAnnotationView *> *)subviews;

View File

@@ -28,7 +28,8 @@ MLN_EXPORT
@return The initialized annotation image object or `nil` if there was a problem
initializing the object.
*/
+ (instancetype)annotationImageWithImage:(UIImage *)image reuseIdentifier:(NSString *)reuseIdentifier;
+ (instancetype)annotationImageWithImage:(UIImage *)image
reuseIdentifier:(NSString *)reuseIdentifier;
// MARK: Getting and Setting Attributes

View File

@@ -86,8 +86,8 @@ MLN_EXPORT
same annotation they were initialized with. Also, annotation views that are in
the reuse queue will have a nil value for the annotation property. Passing an annotation
instance to the view is optional and the map view will automatically associate annotations
with views when views are provided to the map via the `-[MLNMapViewDelegate mapView:viewForAnnotation:]`
method.
with views when views are provided to the map via the `-[MLNMapViewDelegate
mapView:viewForAnnotation:]` method.
The reuse identifier provides a way for you to improve performance by recycling
annotation views as they enter and leave the map’s viewport. As an annotation
@@ -104,7 +104,8 @@ MLN_EXPORT
views.
@return The initialized annotation view object.
*/
- (instancetype)initWithAnnotation:(nullable id<MLNAnnotation>)annotation reuseIdentifier:(nullable NSString *)reuseIdentifier;
- (instancetype)initWithAnnotation:(nullable id<MLNAnnotation>)annotation
reuseIdentifier:(nullable NSString *)reuseIdentifier;
/**
Called when the view is removed from the reuse queue.
@@ -275,7 +276,8 @@ MLN_EXPORT
drags it. As the system detects user actions that would indicate a drag, it
calls this method to update the drag state.
*/
- (void)setDragState:(MLNAnnotationViewDragState)dragState animated:(BOOL)animated NS_REQUIRES_SUPER;
- (void)setDragState:(MLNAnnotationViewDragState)dragState
animated:(BOOL)animated NS_REQUIRES_SUPER;
@end

View File

@@ -1,5 +1,5 @@
#import "MLNAnnotationView.h"
#import "MLNAnnotation.h"
#import "MLNAnnotationView.h"
NS_ASSUME_NONNULL_BEGIN

View File

@@ -47,14 +47,21 @@ NS_ASSUME_NONNULL_BEGIN
Presents a callout view by adding it to `view` and pointing at the given rect
of `view`’s bounds. Constrains the callout to the bounds of the given view.
*/
- (void)presentCalloutFromRect:(CGRect)rect inView:(UIView *)view constrainedToView:(UIView *)constrainedView animated:(BOOL)animated __attribute__((unavailable("Use `-presentCalloutFromRect:inView:constrainedToRect:animated:` instead.")));
- (void)presentCalloutFromRect:(CGRect)rect
inView:(UIView *)view
constrainedToView:(UIView *)constrainedView
animated:(BOOL)animated
__attribute__((
unavailable("Use `-presentCalloutFromRect:inView:constrainedToRect:animated:` instead.")));
/**
Presents a callout view by adding it to `view` and pointing at the given rect
of `view`’s bounds. Constrains the callout to the rect in the space of `view`.
*/
- (void)presentCalloutFromRect:(CGRect)rect inView:(UIView *)view constrainedToRect:(CGRect)constrainedRect animated:(BOOL)animated;
- (void)presentCalloutFromRect:(CGRect)rect
inView:(UIView *)view
constrainedToRect:(CGRect)constrainedRect
animated:(BOOL)animated;
/**
Dismisses the callout view.
@@ -67,19 +74,20 @@ NS_ASSUME_NONNULL_BEGIN
If implemented, should provide margins to expand the rect the callout is presented from.
These are used to determine positioning. Currently only the top and bottom properties of the return
value are used. For example, `{ .top = -50.0, .left = -10.0, .bottom = 0.0, .right = -10.0 }` indicates
a 50 point margin above the presentation origin rect (and 10 point margins to the left and the right)
in which the callout is assumed to be displayed.
value are used. For example, `{ .top = -50.0, .left = -10.0, .bottom = 0.0, .right = -10.0 }`
indicates a 50 point margin above the presentation origin rect (and 10 point margins to the left
and the right) in which the callout is assumed to be displayed.
There are no assumed defaults for these margins, as they should be calculated from the callout that
is to be presented. For example, `SMCalloutView` generates the top margin from the callout height, but
the left and right margins from a minimum width that the callout should have.
is to be presented. For example, `SMCalloutView` generates the top margin from the callout height,
but the left and right margins from a minimum width that the callout should have.
@param rect Rect that the callout is presented from. This should be the same as the one passed in
`-[MLNCalloutView presentCalloutFromRect:inView:constrainedToRect:animated:]`
@return `UIEdgeInsets` representing the margins. Values should be negative.
*/
- (UIEdgeInsets)marginInsetsHintForPresentationFromRect:(CGRect)rect NS_SWIFT_NAME(marginInsetsHintForPresentation(from:));
- (UIEdgeInsets)marginInsetsHintForPresentationFromRect:(CGRect)rect
NS_SWIFT_NAME(marginInsetsHintForPresentation(from:));
/**
A Boolean value indicating whether the callout view should be anchored to

View File

@@ -12,7 +12,8 @@
- `-mapView:regionDidChangeWithReason:animated:`
It's important to note that it's almost impossible to perform a rotate without zooming (in or out),
so if you'll often find `MLNCameraChangeReasonGesturePinch` set alongside `MLNCameraChangeReasonGestureRotate`.
so if you'll often find `MLNCameraChangeReasonGesturePinch` set alongside
`MLNCameraChangeReasonGestureRotate`.
Since there are several reasons why a zoom or rotation has occurred, it is worth considering
creating a combined constant, for example:
@@ -23,16 +24,16 @@
MLNCameraChangeReasonGestureZoomOut |
MLNCameraChangeReasonGestureOneFingerZoom;
static const MLNCameraChangeReason anyRotation = MLNCameraChangeReasonResetNorth | MLNCameraChangeReasonGestureRotate;
static const MLNCameraChangeReason anyRotation = MLNCameraChangeReasonResetNorth |
MLNCameraChangeReasonGestureRotate;
```
*/
typedef NS_OPTIONS(NSUInteger, MLNCameraChangeReason)
{
typedef NS_OPTIONS(NSUInteger, MLNCameraChangeReason) {
/// :nodoc: The reason for the camera change has not be specified.
MLNCameraChangeReasonNone = 0,
/// :nodoc: Set when a public API that moves the camera is called. This may be set for some gestures,
/// for example MLNCameraChangeReasonResetNorth.
/// :nodoc: Set when a public API that moves the camera is called. This may be set for some
/// gestures, for example MLNCameraChangeReasonResetNorth.
MLNCameraChangeReasonProgrammatic = 1 << 0,
/// :nodoc: The user tapped the compass to reset the map orientation so North is up.
@@ -53,7 +54,8 @@ typedef NS_OPTIONS(NSUInteger, MLNCameraChangeReason)
/// :nodoc: The user zoomed the map out (two finger single tap).
MLNCameraChangeReasonGestureZoomOut = 1 << 6,
/// :nodoc: The user long pressed on the map for a quick zoom (single tap, then long press and drag up/down).
/// :nodoc: The user long pressed on the map for a quick zoom (single tap, then long press and
/// drag up/down).
MLNCameraChangeReasonGestureOneFingerZoom = 1 << 7,
// :nodoc: The user panned with two fingers to tilt the map (two finger drag).

View File

@@ -1,5 +1,5 @@
#import "SMCalloutView.h"
#import "MLNCalloutView.h"
#import "SMCalloutView.h"
/**
A concrete implementation of `MLNCalloutView` based on

View File

@@ -13,7 +13,8 @@ MLN_EXPORT
/**
The visibility of the compass button.
You can configure a compass button to be visible all the time or only when the compass heading changes.
You can configure a compass button to be visible all the time or only when the compass heading
changes.
*/
@property (nonatomic, assign) MLNOrnamentVisibility compassVisibility;

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