diff options
author | Jesse Bounds <jesse@rebounds.net> | 2016-10-20 17:14:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-20 17:14:19 -0700 |
commit | 1216050f9c5c472f1c8edcc32447004a40680ec7 (patch) | |
tree | 77f937aaeaa6e34f8b2fa84e5f7c721e8f3d541f /platform/darwin/test | |
parent | baf82fc4d4882480e6dd16ea9821be29d390bf00 (diff) | |
download | qtlocation-mapboxgl-1216050f9c5c472f1c8edcc32447004a40680ec7.tar.gz |
Add MGLPointCollection for GeoJSON multipoints (#6742)
* [ios, macos] Introduce MGLPointCollection
This makes MGLMultiPoint abstract again so that it is only a place
for shared functionality of polygons and polylines. The multipoint
feature replaces the point collection feature and can be
used to initialize a MGLGeoJSONSource. The previously added
swift_names for polyline and polygon are removed, for now.
This also updates the iOS and macOS annotation adding logic so that
unwanted shapes really are avoided. Previously the combined OR
conditions meant that an annotation had to logically be NOT a kind
of all three types so the check always let the annotation slip through.
This also expands the guard to deflect the new MGLPointCollection.
Diffstat (limited to 'platform/darwin/test')
-rw-r--r-- | platform/darwin/test/MGLFeatureTests.mm | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 18c3fd16c2..7f464aaab1 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -227,24 +227,6 @@ XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); } -- (void)testMultiPointFeatureGeoJSONDictionary { - CLLocationCoordinate2D coord1 = { 0, 0 }; - CLLocationCoordinate2D coord2 = { 10, 10 }; - CLLocationCoordinate2D coord3 = { 0, 0 }; - CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 }; - MGLMultiPointFeature *multiPointFeature = [MGLMultiPointFeature multiPointWithCoordinates:coords count:3]; - - // A GeoJSON feature - NSDictionary *geoJSONFeature = [multiPointFeature geoJSONDictionary]; - - // it has the correct geometry - NSDictionary *expectedGeometry = @{@"type": @"MultiPoint", - @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)], - @[@(coord2.longitude), @(coord2.latitude)], - @[@(coord3.longitude), @(coord3.latitude)]]}; - XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); -} - - (void)testMultiPolylineFeatureGeoJSONDictionary { CLLocationCoordinate2D coord1 = { 0, 0 }; CLLocationCoordinate2D coord2 = { 10, 10 }; @@ -296,6 +278,25 @@ XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); } +- (void)testPointCollectionFeatureGeoJSONDictionary { + CLLocationCoordinate2D coord1 = { 0, 0 }; + CLLocationCoordinate2D coord2 = { 10, 10 }; + CLLocationCoordinate2D coord3 = { 0, 0 }; + CLLocationCoordinate2D coords[] = { coord1, coord2, coord3 }; + MGLPointCollectionFeature *pointCollectionFeature = [MGLPointCollectionFeature pointCollectionWithCoordinates:coords count:3]; + + // A GeoJSON feature + NSDictionary *geoJSONFeature = [pointCollectionFeature geoJSONDictionary]; + + // it has the correct geometry + NSDictionary *expectedGeometry = @{@"type": @"MultiPoint", + @"coordinates": @[@[@(coord1.longitude), @(coord1.latitude)], + @[@(coord2.longitude), @(coord2.latitude)], + @[@(coord3.longitude), @(coord3.latitude)]]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); + +} + - (void)testShapeCollectionFeatureGeoJSONDictionary { MGLPointAnnotation *pointFeature = [[MGLPointAnnotation alloc] init]; CLLocationCoordinate2D pointCoordinate = { 10, 10 }; |