summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLPolygon.mm
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2017-05-23 12:32:18 -0400
committerGitHub <noreply@github.com>2017-05-23 12:32:18 -0400
commita57e9bc41093eb8f028dcab3593c3921d887bdc0 (patch)
treee2c379e3deee5de78cb435e6b250fb8528f4ff02 /platform/darwin/src/MGLPolygon.mm
parentfe17f7e8db266a125ac05d805003f5d2bf1548c6 (diff)
downloadqtlocation-mapboxgl-a57e9bc41093eb8f028dcab3593c3921d887bdc0.tar.gz
[ios,macos] multipolygon coordinate (#8713)
* [ios] MGLMultiPolygon's coordinate property implemented * [ios,macos] Add polylabalel to project config * [ios,macos] Change coordinate property for MGLPolyline,MGLPolygon,MGLMultiPolygon * [macos] Change project configuration to support polilabel * [ios,macos] Add MGLLocationCoordinate2DFromPoint * [ios, macos] Update changelogs * [ios, macos] remove unnecesary variables * [ios, macos] Add radians conversions * [ios, macos] Add coordinate calc to MGLPolyline * [ios, macos] Move radian fuctions to MGLGeometry_Private.h * [ios, macos] Fix code style * [ios, macos] Fix code indentation * [ios, macos] Fix radian per meters constant * [ios, macos] Add test scenarios to testPolyline * [ios, macos] Fix test accuracy
Diffstat (limited to 'platform/darwin/src/MGLPolygon.mm')
-rw-r--r--platform/darwin/src/MGLPolygon.mm20
1 files changed, 19 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLPolygon.mm b/platform/darwin/src/MGLPolygon.mm
index ceafe873bf..d966ff13ce 100644
--- a/platform/darwin/src/MGLPolygon.mm
+++ b/platform/darwin/src/MGLPolygon.mm
@@ -6,6 +6,7 @@
#import "MGLPolygon+MGLAdditions.h"
#import <mbgl/util/geojson.hpp>
+#import <mapbox/polylabel.hpp>
@implementation MGLPolygon
@@ -54,6 +55,13 @@
return [super hash] + [[self geoJSONDictionary] hash];
}
+- (CLLocationCoordinate2D)coordinate {
+ // pole of inaccessibility
+ auto poi = mapbox::polylabel([self polygon]);
+
+ return MGLLocationCoordinate2DFromPoint(poi);
+}
+
- (mbgl::LinearRing<double>)ring {
NSUInteger count = self.pointCount;
CLLocationCoordinate2D *coordinates = self.coordinates;
@@ -155,11 +163,17 @@
return hash;
}
+- (CLLocationCoordinate2D)coordinate {
+ MGLPolygon *firstPolygon = self.polygons.firstObject;
+
+ return firstPolygon.coordinate;
+}
+
- (BOOL)intersectsOverlayBounds:(MGLCoordinateBounds)overlayBounds {
return MGLCoordinateBoundsIntersectsCoordinateBounds(_overlayBounds, overlayBounds);
}
-- (mbgl::Geometry<double>)geometryObject {
+- (mbgl::MultiPolygon<double>)multiPolygon {
mbgl::MultiPolygon<double> multiPolygon;
multiPolygon.reserve(self.polygons.count);
for (MGLPolygon *polygon in self.polygons) {
@@ -173,6 +187,10 @@
return multiPolygon;
}
+- (mbgl::Geometry<double>)geometryObject {
+ return [self multiPolygon];
+}
+
- (NSDictionary *)geoJSONDictionary {
NSMutableArray *coordinates = [[NSMutableArray alloc] initWithCapacity:self.polygons.count];
for (MGLPolygonFeature *feature in self.polygons) {