summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-01-08 17:07:06 -0800
committerGitHub <noreply@github.com>2017-01-08 17:07:06 -0800
commit4cee2b1a698e71bfab17a65aab2f873ce50e83c6 (patch)
treeabb735386e0d8c02e4bba5cc472e4837fba528d9
parent901c806916deb30affa7a8a2884069cd28dba4ca (diff)
downloadqtlocation-mapboxgl-4cee2b1a698e71bfab17a65aab2f873ce50e83c6.tar.gz
[ios, macos] Allow creation of shape collections with no shapes (#7632)
-rw-r--r--platform/darwin/src/MGLShapeCollection.h2
-rw-r--r--platform/darwin/src/MGLShapeCollection.mm1
-rw-r--r--platform/darwin/test/MGLFeatureTests.mm9
-rw-r--r--platform/ios/CHANGELOG.md1
-rw-r--r--platform/macos/CHANGELOG.md1
5 files changed, 12 insertions, 2 deletions
diff --git a/platform/darwin/src/MGLShapeCollection.h b/platform/darwin/src/MGLShapeCollection.h
index 343c2a4322..01aece824f 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 c8f0d09f9a..4b468a1cbb 100644
--- a/platform/darwin/src/MGLShapeCollection.mm
+++ b/platform/darwin/src/MGLShapeCollection.mm
@@ -12,7 +12,6 @@
- (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 33c146e723..7d60f53faa 100644
--- a/platform/darwin/test/MGLFeatureTests.mm
+++ b/platform/darwin/test/MGLFeatureTests.mm
@@ -322,6 +322,15 @@
@[@(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 ca86e5b34c..c87e83e4ab 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 e16908232f..0775fa880b 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