Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios, macos] Allow creation of shape collections with no shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
boundsj committed Jan 9, 2017
1 parent 901c806 commit aa48fac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion platform/darwin/src/MGLShapeCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion platform/darwin/src/MGLShapeCollection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions platform/darwin/test/MGLFeatureTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions platform/macos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa48fac

Please sign in to comment.