* [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.
81 lines
2.2 KiB
Plaintext
81 lines
2.2 KiB
Plaintext
#import "MGLShapeCollection.h"
|
|
|
|
#import "MGLShape_Private.h"
|
|
#import "MGLFeature.h"
|
|
#import "MGLLoggingConfiguration_Private.h"
|
|
|
|
#import <mbgl/style/conversion/geojson.hpp>
|
|
|
|
@implementation MGLShapeCollection
|
|
|
|
+ (instancetype)shapeCollectionWithShapes:(NSArray<MGLShape *> *)shapes {
|
|
return [[self alloc] initWithShapes:shapes];
|
|
}
|
|
|
|
- (instancetype)initWithShapes:(NSArray<MGLShape *> *)shapes {
|
|
MGLLogDebug(@"Initializing with %lu shapes.", (unsigned long)shapes.count);
|
|
if (self = [super init]) {
|
|
_shapes = shapes.copy;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithCoder:(NSCoder *)decoder {
|
|
MGLLogInfo(@"Initializing with coder.");
|
|
if (self = [super initWithCoder:decoder]) {
|
|
_shapes = [decoder decodeObjectOfClass:[NSArray class] forKey:@"shapes"];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)encodeWithCoder:(NSCoder *)coder {
|
|
[super encodeWithCoder:coder];
|
|
[coder encodeObject:_shapes forKey:@"shapes"];
|
|
}
|
|
|
|
- (BOOL)isEqual:(id)other {
|
|
if (self == other) return YES;
|
|
if (![other isKindOfClass:[MGLShapeCollection class]]) return NO;
|
|
|
|
MGLShapeCollection *otherShapeCollection = other;
|
|
return [super isEqual:otherShapeCollection]
|
|
&& [_shapes isEqualToArray:otherShapeCollection.shapes];
|
|
}
|
|
|
|
- (NSUInteger)hash {
|
|
NSUInteger hash = [super hash];
|
|
for (MGLShape *shape in _shapes) {
|
|
hash += [shape hash];
|
|
}
|
|
return hash;
|
|
}
|
|
|
|
- (CLLocationCoordinate2D)coordinate {
|
|
return _shapes.firstObject.coordinate;
|
|
}
|
|
|
|
- (NSDictionary *)geoJSONDictionary {
|
|
return @{@"type": @"GeometryCollection",
|
|
@"geometries": [self geometryCollection]};
|
|
}
|
|
|
|
- (NSArray *)geometryCollection {
|
|
NSMutableArray *geometries = [[NSMutableArray alloc] initWithCapacity:self.shapes.count];
|
|
for (id shape in self.shapes) {
|
|
NSDictionary *geometry = [shape geoJSONDictionary];
|
|
[geometries addObject:geometry];
|
|
}
|
|
return [geometries copy];
|
|
}
|
|
|
|
- (mbgl::Geometry<double>)geometryObject {
|
|
mapbox::geojson::geometry_collection collection;
|
|
collection.reserve(self.shapes.count);
|
|
for (MGLShape *shape in self.shapes) {
|
|
collection.push_back([shape geometryObject]);
|
|
}
|
|
return collection;
|
|
}
|
|
|
|
@end
|