* [ios, macos] Update the logging subsystem to platform agnostic. * [ios, macos] Add coordinate to string function. * [ios, macos] Add BOOL to string function. * [ios, macos] Add tracing logs. * [ios, macos] Add tracing logs to generated style classes. * [ios, macos] Split logging categories accordingly to MGLLoggingLevel. * [ios, macos] Log network requests. * [ios, macos] Migrate NSAssert to MGLAssert. * [ios, macos] Include MGLLoggingConfiguration to filesource-files.txt. * [ios, macos] Fix logger string specifier for the line parameter. * [ios, macos] Add logs to shapes classes. * [ios, macos] Add logs to offline classes. * [ios, macos] Add logs to annotation classes. * [ios, macos] Add logs to foundation classes. * [ios, macos] Fix snapshotter size logging. * [macos] Add logs to map view. * [ios, macos] Fix string from boolean prefix, add custom function for NSCAssert. * Log size test * [ios, macos] Add logging conditional compilation flag. * [ios, macos] Rename function NSStringFromMGLTransition to MGLStringFromMGLTransition. * [ios, macos] Remove verbose logging for release builds. * [ios, macos] Rename NSStringFromCLLocationCoordinate2D to MGLStringFromCLLocationCoordinate2D. * [ios, macos] Clean unnecesary blank lines in MGLLight.mm set methods. * [ios, macos] Fix logging grammar, format, function names. * [ios, macos] Remove compilation flag, rename flags.
67 lines
2.5 KiB
Plaintext
67 lines
2.5 KiB
Plaintext
#import "NSArray+MGLAdditions.h"
|
|
|
|
#import "NSDictionary+MGLAdditions.h"
|
|
#import "NSExpression+MGLPrivateAdditions.h"
|
|
#import "MGLLoggingConfiguration_Private.h"
|
|
|
|
@implementation NSArray (MGLAdditions)
|
|
|
|
- (std::vector<mbgl::Value>)mgl_vector {
|
|
std::vector<mbgl::Value> vector;
|
|
vector.reserve(self.count);
|
|
for (id value in self) {
|
|
if ([value isKindOfClass:[NSArray class]]) {
|
|
std::vector<mbgl::Value> innerVector = [value mgl_vector];
|
|
vector.push_back(innerVector);
|
|
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
|
mbgl::PropertyMap propertyMap = [value mgl_propertyMap];
|
|
vector.push_back(propertyMap);
|
|
} else {
|
|
NSExpression *expression = [NSExpression expressionForConstantValue:value];
|
|
vector.push_back(expression.mgl_constantMBGLValue);
|
|
}
|
|
}
|
|
return vector;
|
|
}
|
|
|
|
- (NSAttributedString *)mgl_attributedComponentsJoinedByString:(NSString *)separator {
|
|
NSAttributedString *attributedSeparator = [[NSAttributedString alloc] initWithString:separator];
|
|
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
|
|
BOOL isSubsequentItem = NO;
|
|
for (NSAttributedString *component in self) {
|
|
MGLAssert([component isKindOfClass:[NSAttributedString class]], @"Items in array must be attributed strings.");
|
|
if (isSubsequentItem) {
|
|
[attributedString appendAttributedString:attributedSeparator];
|
|
}
|
|
isSubsequentItem = YES;
|
|
[attributedString appendAttributedString:component];
|
|
}
|
|
return attributedString;
|
|
}
|
|
|
|
+ (NSArray *)mgl_coordinatesFromCoordinates:(std::vector<CLLocationCoordinate2D>)coords {
|
|
NSMutableArray *coordinates = [NSMutableArray array];
|
|
for (auto coord : coords) {
|
|
[coordinates addObject:@{@"latitude": @(coord.latitude),
|
|
@"longitude": @(coord.longitude)}];
|
|
}
|
|
return coordinates;
|
|
}
|
|
|
|
- (std::vector<CLLocationCoordinate2D>)mgl_coordinates {
|
|
NSUInteger numberOfCoordinates = [self count];
|
|
CLLocationCoordinate2D *coords = (CLLocationCoordinate2D *)malloc(numberOfCoordinates * sizeof(CLLocationCoordinate2D));
|
|
|
|
for (NSUInteger i = 0; i < numberOfCoordinates; i++) {
|
|
coords[i] = CLLocationCoordinate2DMake([self[i][@"latitude"] doubleValue],
|
|
[self[i][@"longitude"] doubleValue]);
|
|
}
|
|
|
|
std::vector<CLLocationCoordinate2D> coordinates = { coords, coords + numberOfCoordinates };
|
|
free(coords);
|
|
|
|
return coordinates;
|
|
}
|
|
|
|
@end
|