diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-05-25 14:35:38 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-05-27 21:42:38 -0700 |
commit | de905ab64c34e0fd8e35603c4f4fc338d76f89b2 (patch) | |
tree | 1f7715b39159cb970d27fe852dc2a5c6f3ae8235 /platform/darwin/test/MGLFeatureTests.mm | |
parent | 4ab98387f1fda80b7bf9328d5aee77f37363d068 (diff) | |
download | qtlocation-mapboxgl-de905ab64c34e0fd8e35603c4f4fc338d76f89b2.tar.gz |
[ios, osx] Holes in polygons
MGLPolygon (and by extension MGLMultiPolygon) now supports interior rings. The data is preserved in feature querying results, and interior rings are respected when adding polygon overlays to the map.
Fixes #1729.
[ios, osx] Updated changelog
Diffstat (limited to 'platform/darwin/test/MGLFeatureTests.mm')
-rw-r--r-- | platform/darwin/test/MGLFeatureTests.mm | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index d9334c76af..6cf038d4fb 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -23,10 +23,16 @@ mapbox::geometry::polygon<double> polygon = { { - { -77.0325453144239, 38.9131982 }, - { -122.4135302, 37.7757368 }, - { 77.6368034, 12.9810816 }, - { -74.2178961777998, -13.15589555 }, + { 1, 1 }, + { 4, 1 }, + { 4, 4 }, + { 1, 4 }, + }, + { + { 2, 2 }, + { 3, 2 }, + { 3, 3 }, + { 2, 3 }, }, }; features.emplace_back(polygon); @@ -52,6 +58,30 @@ MGLPolygonFeature *polygonShape = (MGLPolygonFeature *)shapes[2]; XCTAssertTrue([polygonShape isKindOfClass:[MGLPolygonFeature class]]); XCTAssertEqual(polygonShape.pointCount, 4); + CLLocationCoordinate2D *polygonCoordinates = polygonShape.coordinates; + XCTAssertNotEqual(polygonCoordinates, nil); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[0]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(1, 1)]); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[1]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(1, 4)]); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[2]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(4, 4)]); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:polygonCoordinates[3]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(4, 1)]); + NS_ARRAY_OF(MGLPolygon *) *interiorPolygons = polygonShape.interiorPolygons; + XCTAssertEqual(interiorPolygons.count, 1); + MGLPolygon *interiorPolygon = interiorPolygons.firstObject; + XCTAssertEqual(interiorPolygon.pointCount, 4); + CLLocationCoordinate2D interiorPolygonCoordinates[4]; + [interiorPolygon getCoordinates:interiorPolygonCoordinates range:NSMakeRange(0, interiorPolygon.pointCount)]; + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[0]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(2, 2)]); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[1]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(2, 3)]); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[2]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(3, 3)]); + XCTAssertEqualObjects([NSValue valueWithMGLCoordinate:interiorPolygonCoordinates[3]], + [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(3, 2)]); } - (void)testPropertyConversion { |