summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLFeature.mm
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2018-12-11 17:07:47 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2018-12-13 19:38:50 +0200
commitb6b1067caf6ba911efbb4a64a43425ce2d729a1a (patch)
tree3bdc97f4ed23e6b3abeb47c85a6b559a813059ac /platform/darwin/src/MGLFeature.mm
parent1d410c94fc6bd6d9f4880f22193328403302a847 (diff)
downloadqtlocation-mapboxgl-b6b1067caf6ba911efbb4a64a43425ce2d729a1a.tar.gz
[ios, darwin] Make MGLFeature.attributes non-nullable and add integration test
Enforce non-nullable semantics for MGLFeature.attributes, to avoid construction of invalid mbgl::Feature properties from nil NSDictionary object and align with public SDK property definition. Integration test "testShapeSourceWithLineDistanceMetrics" is added to verify that MGLFeature is correctly converted. Fixes issue #13378
Diffstat (limited to 'platform/darwin/src/MGLFeature.mm')
-rw-r--r--platform/darwin/src/MGLFeature.mm26
1 files changed, 17 insertions, 9 deletions
diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm
index 3b6a2ee488..d24c807625 100644
--- a/platform/darwin/src/MGLFeature.mm
+++ b/platform/darwin/src/MGLFeature.mm
@@ -25,11 +25,12 @@
@implementation MGLEmptyFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -60,11 +61,12 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLPointFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -96,11 +98,12 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLPolylineFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -133,11 +136,12 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLPolygonFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -170,11 +174,12 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLPointCollectionFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -197,11 +202,12 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLMultiPolylineFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -234,11 +240,12 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLMultiPolygonFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
MGLLogDebug(@"Retrieving attributeForKey: %@", key);
@@ -271,7 +278,7 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
@implementation MGLShapeCollectionFeature
@synthesize identifier;
-@synthesize attributes;
+@synthesize attributes = _attributes;
@dynamic shapes;
@@ -282,6 +289,7 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
MGL_DEFINE_FEATURE_INIT_WITH_CODER();
MGL_DEFINE_FEATURE_ENCODE();
MGL_DEFINE_FEATURE_IS_EQUAL();
+MGL_DEFINE_FEATURE_ATTRIBUTES_GETTER();
- (id)attributeForKey:(NSString *)key {
return self.attributes[key];
@@ -463,7 +471,7 @@ mbgl::Feature mbglFeature(mbgl::Feature feature, id identifier, NSDictionary *at
NSDictionary<NSString *, id> *NSDictionaryFeatureForGeometry(NSDictionary *geometry, NSDictionary *attributes, id identifier) {
NSMutableDictionary *feature = [@{@"type": @"Feature",
- @"properties": (attributes) ?: [NSNull null],
+ @"properties": attributes,
@"geometry": geometry} mutableCopy];
feature[@"id"] = identifier;
return [feature copy];