diff options
Diffstat (limited to 'platform/darwin/src/NSArray+MGLAdditions.mm')
-rw-r--r-- | platform/darwin/src/NSArray+MGLAdditions.mm | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/platform/darwin/src/NSArray+MGLAdditions.mm b/platform/darwin/src/NSArray+MGLAdditions.mm index b2799c46e1..8ec344f580 100644 --- a/platform/darwin/src/NSArray+MGLAdditions.mm +++ b/platform/darwin/src/NSArray+MGLAdditions.mm @@ -17,9 +17,9 @@ vector.push_back(propertyMap); } else { NSExpression *expression = [NSExpression expressionForConstantValue:value]; - vector.push_back([expression mgl_filterValue]); + vector.push_back(expression.mgl_constantMBGLValue); } - } + } return vector; } @@ -38,4 +38,28 @@ 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 |