diff options
Diffstat (limited to 'platform/darwin/src/MGLPolygon.mm')
-rw-r--r-- | platform/darwin/src/MGLPolygon.mm | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm index d966ff13ce..2af768d514 100644 --- a/platform/darwin/src/MGLPolygon.mm +++ b/platform/darwin/src/MGLPolygon.mm @@ -1,9 +1,9 @@ -#import "MGLPolygon.h" +#import "MGLPolygon_Private.h" #import "MGLMultiPoint_Private.h" #import "MGLGeometry_Private.h" -#import "MGLPolygon+MGLAdditions.h" +#import "MGLFeature.h" #import <mbgl/util/geojson.hpp> #import <mapbox/polylabel.hpp> @@ -102,6 +102,28 @@ @"coordinates": self.mgl_coordinates}; } +- (NS_ARRAY_OF(id) *)mgl_coordinates { + NSMutableArray *coordinates = [NSMutableArray array]; + + NSMutableArray *exteriorRing = [NSMutableArray array]; + for (NSUInteger index = 0; index < self.pointCount; index++) { + CLLocationCoordinate2D coordinate = self.coordinates[index]; + [exteriorRing addObject:@[@(coordinate.longitude), @(coordinate.latitude)]]; + } + [coordinates addObject:exteriorRing]; + + for (MGLPolygon *interiorPolygon in self.interiorPolygons) { + NSMutableArray *interiorRing = [NSMutableArray array]; + for (int index = 0; index < interiorPolygon.pointCount; index++) { + CLLocationCoordinate2D coordinate = interiorPolygon.coordinates[index]; + [interiorRing addObject:@[@(coordinate.longitude), @(coordinate.latitude)]]; + } + [coordinates addObject:interiorRing]; + } + + return [coordinates copy]; +} + @end @interface MGLMultiPolygon () @@ -200,4 +222,14 @@ @"coordinates": coordinates}; } +- (NSString *)description +{ + return [NSString stringWithFormat:@"<%@: %p; title = %@, subtitle: = %@, count = %lu; bounds = %@>", + NSStringFromClass([self class]), (void *)self, + self.title ? [NSString stringWithFormat:@"\"%@\"", self.title] : self.title, + self.subtitle ? [NSString stringWithFormat:@"\"%@\"", self.subtitle] : self.subtitle, + (unsigned long)self.polygons.count, + MGLStringFromCoordinateBounds(self.overlayBounds)]; +} + @end |