diff --git a/platform/darwin/src/MGLShapeCollection.h b/platform/darwin/src/MGLShapeCollection.h index 343c2a43228..01aece824f6 100644 --- a/platform/darwin/src/MGLShapeCollection.h +++ b/platform/darwin/src/MGLShapeCollection.h @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN /** - An `MGLShapeCollection` object represents a shape consisting of one or more + An `MGLShapeCollection` object represents a shape consisting of zero or more distinct but related shapes that are instances of `MGLShape`. The constituent shapes can be a mixture of different kinds of shapes. diff --git a/platform/darwin/src/MGLShapeCollection.mm b/platform/darwin/src/MGLShapeCollection.mm index c8f0d09f9a9..4b468a1cbb3 100644 --- a/platform/darwin/src/MGLShapeCollection.mm +++ b/platform/darwin/src/MGLShapeCollection.mm @@ -12,7 +12,6 @@ + (instancetype)shapeCollectionWithShapes:(NS_ARRAY_OF(MGLShape *) *)shapes { - (instancetype)initWithShapes:(NS_ARRAY_OF(MGLShape *) *)shapes { if (self = [super init]) { - NSAssert(shapes.count, @"Cannot create an empty shape collection"); _shapes = shapes.copy; } return self; diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 33c146e7231..7d60f53faaf 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -322,6 +322,15 @@ - (void)testShapeCollectionFeatureGeoJSONDictionary { @[@(coord2.longitude), @(coord2.latitude)]]} ]}; XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); + + // When the shape collection is created with an empty array of shapes + shapeCollectionFeature = [MGLShapeCollectionFeature shapeCollectionWithShapes:@[]]; + + // it has the correct (empty) geometry + geoJSONFeature = [shapeCollectionFeature geoJSONDictionary]; + expectedGeometry = @{@"type": @"GeometryCollection", + @"geometries": @[]}; + XCTAssertEqualObjects(geoJSONFeature[@"geometry"], expectedGeometry); } @end diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index ca86e5b34c2..c87e83e4ab5 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -63,6 +63,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Fixed an issue that caused an annotation view to disappear if it isn’t created using the annotation view reuse queue. ([#6485](https://github.com/mapbox/mapbox-gl-native/pull/6485)) * Fixed an issue that could reset user-added transformations on annotation views. ([#6166](https://github.com/mapbox/mapbox-gl-native/pull/6166)) * Improved the performance of relocating a non-view-backed point annotation by changing its `coordinate` property. ([#5385](https://github.com/mapbox/mapbox-gl-native/pull/5385)) +* Fixed an issue that caused an assertion failure if a `MGLShapeCollection` (a GeoJSON GeometryCollection) was created with an empty array of shapes. ([#7632](https://github.com/mapbox/mapbox-gl-native/pull/7632)) * Improved the precision of annotations at zoom levels greater than 18. ([#5517](https://github.com/mapbox/mapbox-gl-native/pull/5517)) ### Networking and offline maps diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index e16908232f1..0775fa880b3 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -43,6 +43,7 @@ This version of the Mapbox macOS SDK corresponds to version 3.4.0 of the Mapbox * Various method arguments that are represented as C arrays of `CLLocationCoordinate2D` instances have been marked `const` to streamline bridging to Swift. ([#7215](https://github.com/mapbox/mapbox-gl-native/pull/7215)) * To make an MGLPolyline or MGLPolygon span the antimeridian, specify coordinates with longitudes greater than 180° or less than −180°. ([#6088](https://github.com/mapbox/mapbox-gl-native/pull/6088)) * Fixed an issue where placing a point annotation on Null Island also placed a duplicate annotation on its antipode. ([#3563](https://github.com/mapbox/mapbox-gl-native/pull/3563)) +* Fixed an issue that caused an assertion failure if a `MGLShapeCollection` (a GeoJSON GeometryCollection) was created with an empty array of shapes. ([#7632](https://github.com/mapbox/mapbox-gl-native/pull/7632)) * Improved the precision of annotations at zoom levels greater than 18. ([#5517](https://github.com/mapbox/mapbox-gl-native/pull/5517)) ### Networking and offline maps