summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-09-01 13:26:09 -0700
committerJesse Bounds <jesse@rebounds.net>2016-09-02 14:48:37 -0700
commit08f55af91491033c3da2b5a3de1e7bcb900b8964 (patch)
treee60d7a48e3440736054afe01b6a429dba8241bff
parentad095e458db7eee4085ec8be2528cdfa257371fd (diff)
downloadqtlocation-mapboxgl-08f55af91491033c3da2b5a3de1e7bcb900b8964.tar.gz
[ios, macos] Use NSDictionary for geojson source options.
This removes a previous implementation of geojson options that used a new type to transfer the data around. Added in its place is an options API that takes an NSDictionary that works similarly to NSAttributedString and many other Cocoa APIs that take options. The options parser now expects the developer to send values of the type noted in the documentation and it simply converts the NSNumber to the correct type (integer, double, or bool) for mbgl. However, an exception is raised if the value is not an NSNumber.
-rw-r--r--platform/darwin/src/MGLGeoJSONOptions.h13
-rw-r--r--platform/darwin/src/MGLGeoJSONOptions.m19
-rw-r--r--platform/darwin/src/MGLGeoJSONSource.h66
-rw-r--r--platform/darwin/src/MGLGeoJSONSource.mm105
-rw-r--r--platform/darwin/src/MGLGeoJSONSource_Private.h9
-rw-r--r--platform/darwin/src/MGLRasterSource.mm2
-rw-r--r--platform/darwin/src/MGLSource.mm2
-rw-r--r--platform/darwin/src/MGLSource_Private.h2
-rw-r--r--platform/darwin/src/MGLStyle.mm2
-rw-r--r--platform/darwin/src/MGLVectorSource.mm2
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj30
-rw-r--r--platform/ios/src/Mapbox.h1
-rw-r--r--platform/ios/test/MGLGeoJSONSourceTests.mm39
13 files changed, 218 insertions, 74 deletions
diff --git a/platform/darwin/src/MGLGeoJSONOptions.h b/platform/darwin/src/MGLGeoJSONOptions.h
deleted file mode 100644
index 50b6d0ae6e..0000000000
--- a/platform/darwin/src/MGLGeoJSONOptions.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface MGLGeoJSONOptions : NSObject
-
-@property (nonatomic, assign) NSInteger maximumZoom;
-@property (nonatomic, assign) NSInteger buffer;
-@property (nonatomic, assign) double tolerance;
-
-@property (nonatomic, assign) BOOL cluster;
-@property (nonatomic, assign) NSInteger clusterRadius;
-@property (nonatomic, assign) NSInteger clusterMaximumZoom;
-
-@end
diff --git a/platform/darwin/src/MGLGeoJSONOptions.m b/platform/darwin/src/MGLGeoJSONOptions.m
deleted file mode 100644
index bab99ef88d..0000000000
--- a/platform/darwin/src/MGLGeoJSONOptions.m
+++ /dev/null
@@ -1,19 +0,0 @@
-#import "MGLGeoJSONOptions.h"
-
-@implementation MGLGeoJSONOptions
-
-- (instancetype)init
-{
- if (self = [super init]) {
- _maximumZoom = 18;
- _buffer = 128;
- _tolerance = 0.375;
-
- _cluster = NO;
- _clusterRadius = 50;
- _clusterMaximumZoom = 17;
- }
- return self;
-}
-
-@end
diff --git a/platform/darwin/src/MGLGeoJSONSource.h b/platform/darwin/src/MGLGeoJSONSource.h
index a12c0b64e1..50cab015b0 100644
--- a/platform/darwin/src/MGLGeoJSONSource.h
+++ b/platform/darwin/src/MGLGeoJSONSource.h
@@ -1,12 +1,55 @@
#import "MGLSource.h"
#import "MGLTypes.h"
-#import "MGLGeoJSONOptions.h"
NS_ASSUME_NONNULL_BEGIN
@protocol MGLFeature;
+/**
+ An `NSNumber` object containing a Boolean enabling or disabling clustering.
+ If the `features` property contains point features, setting this option to
+ `YES` clusters the points by radius into groups. The default value is `NO`.
+ */
+extern NSString * const MGLGeoJSONClusterOption;
+
+/**
+ An `NSNumber` object containing an integer; specifies the radius of each
+ cluster when clustering points, measured in <sup>1</sup>/<sub>512</sub>ths of a
+ tile. The default value is 50.
+ */
+extern NSString * const MGLGeoJSONClusterRadiusOption;
+
+/**
+ An `NSNumber` object containing an integer; specifies the maximum zoom level at
+ which to cluster points. Defaults to one zoom level less than the value of
+ `MGLGeoJSONMaximumZoomLevelOption`, so that at the last zoom level, the
+ features are not clustered.
+ */
+extern NSString * const MGLGeoJSONClusterMaximumZoomLevelOption;
+
+/**
+ An `NSNumber` object containing an integer; specifies the maximum zoom level at
+ which to create vector tiles. A greater value produces greater detail at high
+ zoom levels. The default value is 18.
+ */
+extern NSString * const MGLGeoJSONMaximumZoomLevelOption;
+
+/**
+ An `NSNumber` object containing an integer; specifies the tile buffer size on
+ each side. This option is measured in <sup>1</sup>/<sub>512</sub>ths of a tile.
+ A higher value reduces rendering artifacts near tile edges but may impact
+ performance. The default value is 128.
+ */
+extern NSString * const MGLGeoJSONBufferOption;
+
+/**
+ An `NSNumber` object containing a double; specifies the Douglas-Peucker
+ simplification tolerance. A greater value produces simpler geometries and
+ improves performance. The default value is 0.375.
+ */
+extern NSString * const MGLGeoJSONToleranceOption;
+
@interface MGLGeoJSONSource : MGLSource
/**
@@ -39,8 +82,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, readonly, nullable) NSURL *URL;
-@property (nonatomic, readonly, nullable) MGLGeoJSONOptions *geoJSONOptions;
-
/**
Initializes a source with the given identifier and GeoJSON data.
@@ -49,7 +90,14 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data NS_DESIGNATED_INITIALIZER;
-- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data options:(MGLGeoJSONOptions *)options NS_DESIGNATED_INITIALIZER;
+/**
+ Initializes a source with the given identifier, GeoJSON data, and a dictionary of options for the source.
+
+ @param sourceIdentifier A string that uniquely identifies the source.
+ @param geoJSONData An NSData object representing GeoJSON source code.
+ @param options An NSDictionary of attributes for this source specified by the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a>.
+ */
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data options:(NS_DICTIONARY_OF(NSString *, id) *)options NS_DESIGNATED_INITIALIZER;
/**
Initializes a source with the given identifier and URL.
@@ -60,6 +108,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url NS_DESIGNATED_INITIALIZER;
+/**
+ Initializes a source with the given identifier, a URL, and a dictionary of options for the source.
+
+ @param sourceIdentifier A string that uniquely identifies the source.
+ @param URL An HTTP(S) URL, absolute file URL, or local file URL relative to the
+ current application’s resource bundle.
+ @param options An NSDictionary of attributes for this source specified by the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a>.
+ */
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url options:(NS_DICTIONARY_OF(NSString *, id) *)options NS_DESIGNATED_INITIALIZER;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLGeoJSONSource.mm b/platform/darwin/src/MGLGeoJSONSource.mm
index 46bea779a3..652644be47 100644
--- a/platform/darwin/src/MGLGeoJSONSource.mm
+++ b/platform/darwin/src/MGLGeoJSONSource.mm
@@ -7,48 +7,113 @@
#include <mbgl/style/sources/geojson_source.hpp>
+NSString * const MGLGeoJSONClusterOption = @"MGLGeoJSONCluster";
+NSString * const MGLGeoJSONClusterRadiusOption = @"MGLGeoJSONClusterRadius";
+NSString * const MGLGeoJSONClusterMaximumZoomLevelOption = @"MGLGeoJSONClusterMaximumZoomLevel";
+NSString * const MGLGeoJSONMaximumZoomLevelOption = @"MGLGeoJSONMaximumZoomLevel";
+NSString * const MGLGeoJSONBufferOption = @"MGLGeoJSONBuffer";
+NSString * const MGLGeoJSONToleranceOption = @"MGLGeoJSONOptionsClusterTolerance";
+
+@interface MGLGeoJSONSource ()
+
+@property (nonatomic, readwrite) NSDictionary *options;
+
+@end
+
@implementation MGLGeoJSONSource
-- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data {
- if (self = [super initWithSourceIdentifier:sourceIdentifier]) {
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data
+{
+ if (self = [super initWithSourceIdentifier:sourceIdentifier])
+ {
_geoJSONData = data;
}
return self;
}
-- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data options:(MGLGeoJSONOptions *)options
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier geoJSONData:(NSData *)data options:(NS_DICTIONARY_OF(NSString *, id) *)options
{
- if (self = [super initWithSourceIdentifier:sourceIdentifier]) {
+ if (self = [super initWithSourceIdentifier:sourceIdentifier])
+ {
_geoJSONData = data;
- _geoJSONOptions = options;
+ _options = options;
}
return self;
}
-- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url {
- if (self = [super initWithSourceIdentifier:sourceIdentifier]) {
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url
+{
+ if (self = [super initWithSourceIdentifier:sourceIdentifier])
+ {
_URL = url;
}
return self;
}
-- (mbgl::style::GeoJSONOptions)mbgl_geoJSONOptions
+- (instancetype)initWithSourceIdentifier:(NSString *)sourceIdentifier URL:(NSURL *)url options:(NS_DICTIONARY_OF(NSString *, id) *)options
+{
+ if (self = [super initWithSourceIdentifier:sourceIdentifier])
+ {
+ _URL = url;
+ _options = options;
+ }
+ return self;
+}
+
+- (mbgl::style::GeoJSONOptions)geoJSONOptions
+{
+ auto mbglOptions = mbgl::style::GeoJSONOptions();
+
+ if (self.options[MGLGeoJSONMaximumZoomLevelOption]) {
+ id value = self.options[MGLGeoJSONMaximumZoomLevelOption];
+ [self validateValue:value];
+ mbglOptions.maxzoom = [value integerValue];
+ }
+
+ if (self.options[MGLGeoJSONBufferOption]) {
+ id value = self.options[MGLGeoJSONBufferOption];
+ [self validateValue:value];
+ mbglOptions.buffer = [value integerValue];
+ }
+
+ if (self.options[MGLGeoJSONToleranceOption]) {
+ id value = self.options[MGLGeoJSONToleranceOption];
+ [self validateValue:value];
+ mbglOptions.tolerance = [value doubleValue];
+ }
+
+ if (self.options[MGLGeoJSONClusterRadiusOption]) {
+ id value = self.options[MGLGeoJSONClusterRadiusOption];
+ [self validateValue:value];
+ mbglOptions.clusterRadius = [value integerValue];
+ }
+
+ if (self.options[MGLGeoJSONClusterMaximumZoomLevelOption]) {
+ id value = self.options[MGLGeoJSONClusterMaximumZoomLevelOption];
+ [self validateValue:value];
+ mbglOptions.clusterMaxZoom = [value integerValue];
+ }
+
+ if (self.options[MGLGeoJSONClusterOption]) {
+ id value = self.options[MGLGeoJSONClusterOption];
+ [self validateValue:value];
+ mbglOptions.cluster = [value boolValue];
+ }
+
+ return mbglOptions;
+}
+
+- (void)validateValue:(id)value
{
- auto options = mbgl::style::GeoJSONOptions();
- options.maxzoom = self.geoJSONOptions.maximumZoom;
- options.buffer = self.geoJSONOptions.buffer;
- options.tolerance = self.geoJSONOptions.tolerance;
- options.cluster = self.geoJSONOptions.cluster;
- options.clusterRadius = self.geoJSONOptions.clusterRadius;
- options.clusterMaxZoom = self.geoJSONOptions.clusterMaximumZoom;
- return options;
+ if (! [value isKindOfClass:[NSNumber class]])
+ {
+ [NSException raise:@"Value not handled" format:@"%@ is not an NSNumber", value];
+ }
}
-- (std::unique_ptr<mbgl::style::Source>)mbgl_source
+- (std::unique_ptr<mbgl::style::Source>)mbglSource
{
- auto source = self.geoJSONOptions
- ? std::make_unique<mbgl::style::GeoJSONSource>(self.sourceIdentifier.UTF8String, [self mbgl_geoJSONOptions])
- : std::make_unique<mbgl::style::GeoJSONSource>(self.sourceIdentifier.UTF8String);
+ auto source = std::make_unique<mbgl::style::GeoJSONSource>(self.sourceIdentifier.UTF8String, [self geoJSONOptions]);
if (self.URL) {
NSURL *url = self.URL.mgl_URLByStandardizingScheme;
diff --git a/platform/darwin/src/MGLGeoJSONSource_Private.h b/platform/darwin/src/MGLGeoJSONSource_Private.h
new file mode 100644
index 0000000000..3aeb07ad25
--- /dev/null
+++ b/platform/darwin/src/MGLGeoJSONSource_Private.h
@@ -0,0 +1,9 @@
+#import "MGLGeoJSONSource_Private.h"
+
+#include <mbgl/style/sources/geojson_source.hpp>
+
+@interface MGLGeoJSONSource (Private)
+
+- (mbgl::style::GeoJSONOptions)geoJSONOptions;
+
+@end
diff --git a/platform/darwin/src/MGLRasterSource.mm b/platform/darwin/src/MGLRasterSource.mm
index ad2530fc82..15ca2fc558 100644
--- a/platform/darwin/src/MGLRasterSource.mm
+++ b/platform/darwin/src/MGLRasterSource.mm
@@ -14,7 +14,7 @@
return self;
}
-- (std::unique_ptr<mbgl::style::Source>)mbgl_source {
+- (std::unique_ptr<mbgl::style::Source>)mbglSource {
auto source = std::make_unique<mbgl::style::RasterSource>(self.sourceIdentifier.UTF8String,
self.URL.absoluteString.UTF8String,
uint16_t(self.tileSize));
diff --git a/platform/darwin/src/MGLSource.mm b/platform/darwin/src/MGLSource.mm
index 2b73074b09..cdf003cb00 100644
--- a/platform/darwin/src/MGLSource.mm
+++ b/platform/darwin/src/MGLSource.mm
@@ -11,7 +11,7 @@
return self;
}
-- (std::unique_ptr<mbgl::style::Source>)mbgl_source {
+- (std::unique_ptr<mbgl::style::Source>)mbglSource {
[NSException raise:@"Subclasses must override this method" format:@""];
return nil;
}
diff --git a/platform/darwin/src/MGLSource_Private.h b/platform/darwin/src/MGLSource_Private.h
index b4e3c1ebc3..2b8658b4cb 100644
--- a/platform/darwin/src/MGLSource_Private.h
+++ b/platform/darwin/src/MGLSource_Private.h
@@ -5,7 +5,7 @@
@interface MGLSource (Private)
-- (std::unique_ptr<mbgl::style::Source>)mbgl_source;
+- (std::unique_ptr<mbgl::style::Source>)mbglSource;
@property (nonatomic) mbgl::style::Source *source;
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index e392cead3f..02f15ed16f 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -181,7 +181,7 @@ static NSURL *MGLStyleURL_emerald;
- (void)addSource:(MGLSource *)source
{
- self.mapView.mbglMap->addSource([source mbgl_source]);
+ self.mapView.mbglMap->addSource([source mbglSource]);
}
- (void)removeSource:(MGLSource *)source
diff --git a/platform/darwin/src/MGLVectorSource.mm b/platform/darwin/src/MGLVectorSource.mm
index 130144584b..d0c9b0126a 100644
--- a/platform/darwin/src/MGLVectorSource.mm
+++ b/platform/darwin/src/MGLVectorSource.mm
@@ -15,7 +15,7 @@ static NSString *MGLVectorSourceType = @"vector";
return self;
}
-- (std::unique_ptr<mbgl::style::Source>)mbgl_source
+- (std::unique_ptr<mbgl::style::Source>)mbglSource
{
auto source = std::make_unique<mbgl::style::VectorSource>(self.sourceIdentifier.UTF8String, self.URL.absoluteString.UTF8String);
return std::move(source);
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index e2977e9070..6c71b1b3df 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -150,10 +150,6 @@
35E1A4D81D74336F007AA97F /* MGLValueEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E1A4D71D74336F007AA97F /* MGLValueEvaluator.h */; };
35E1A4D91D74336F007AA97F /* MGLValueEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E1A4D71D74336F007AA97F /* MGLValueEvaluator.h */; };
35E208A71D24210F00EC9A46 /* MGLNSDataAdditionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */; };
- 35E751DC1D76BE9800DFF553 /* MGLGeoJSONOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E751DA1D76BE9800DFF553 /* MGLGeoJSONOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 35E751DD1D76BE9800DFF553 /* MGLGeoJSONOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E751DA1D76BE9800DFF553 /* MGLGeoJSONOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 35E751DE1D76BE9800DFF553 /* MGLGeoJSONOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 35E751DB1D76BE9800DFF553 /* MGLGeoJSONOptions.m */; };
- 35E751DF1D76BE9800DFF553 /* MGLGeoJSONOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 35E751DB1D76BE9800DFF553 /* MGLGeoJSONOptions.m */; };
35E79F201D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; };
35E79F211D41266300957B9E /* MGLStyleLayer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */; };
36F1153D1D46080700878E1A /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 36F1153B1D46080700878E1A /* libmbgl-core.a */; };
@@ -163,9 +159,12 @@
4018B1CA1CDC288E00F666AF /* MGLAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */; settings = {ATTRIBUTES = (Public, ); }; };
4018B1CB1CDC288E00F666AF /* MGLAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */; settings = {ATTRIBUTES = (Public, ); }; };
404326891D5B9B27007111BD /* MGLAnnotationContainerView_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404326881D5B9B1A007111BD /* MGLAnnotationContainerView_Private.h */; };
+ 40CFA6511D7875BB008103BD /* MGLGeoJSONSourceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 40CFA6501D787579008103BD /* MGLGeoJSONSourceTests.mm */; };
40EDA1C01CFE0E0200D9EA68 /* MGLAnnotationContainerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */; };
40EDA1C11CFE0E0500D9EA68 /* MGLAnnotationContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */; };
40EDA1C21CFE0E0500D9EA68 /* MGLAnnotationContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */; };
+ 40F887701D7A1E58008ECB67 /* MGLGeoJSONSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLGeoJSONSource_Private.h */; };
+ 40F887711D7A1E59008ECB67 /* MGLGeoJSONSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40F8876F1D7A1DB8008ECB67 /* MGLGeoJSONSource_Private.h */; };
40FDA76B1CCAAA6800442548 /* MBXAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */; };
554180421D2E97DE00012372 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554180411D2E97DE00012372 /* OpenGLES.framework */; };
55D8C9961D0F18CE00F42F10 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 55D8C9951D0F18CE00F42F10 /* libsqlite3.tbd */; };
@@ -562,8 +561,6 @@
35E0CFE51D3E501500188327 /* MGLStyle_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyle_Private.h; sourceTree = "<group>"; };
35E1A4D71D74336F007AA97F /* MGLValueEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLValueEvaluator.h; sourceTree = "<group>"; };
35E208A61D24210F00EC9A46 /* MGLNSDataAdditionsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLNSDataAdditionsTests.m; sourceTree = "<group>"; };
- 35E751DA1D76BE9800DFF553 /* MGLGeoJSONOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLGeoJSONOptions.h; sourceTree = "<group>"; };
- 35E751DB1D76BE9800DFF553 /* MGLGeoJSONOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLGeoJSONOptions.m; sourceTree = "<group>"; };
35E79F1F1D41266300957B9E /* MGLStyleLayer_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleLayer_Private.h; sourceTree = "<group>"; };
36F1153B1D46080700878E1A /* libmbgl-core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-core.a"; path = "build/Debug-iphoneos/libmbgl-core.a"; sourceTree = "<group>"; };
36F1153C1D46080700878E1A /* libmbgl-platform-ios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libmbgl-platform-ios.a"; path = "build/Debug-iphoneos/libmbgl-platform-ios.a"; sourceTree = "<group>"; };
@@ -572,8 +569,10 @@
4018B1C51CDC277F00F666AF /* MGLAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationView.h; sourceTree = "<group>"; };
402E9DE01CD2C76200FD4519 /* Mapbox.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Mapbox.playground; sourceTree = "<group>"; };
404326881D5B9B1A007111BD /* MGLAnnotationContainerView_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationContainerView_Private.h; sourceTree = "<group>"; };
+ 40CFA6501D787579008103BD /* MGLGeoJSONSourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLGeoJSONSourceTests.mm; sourceTree = "<group>"; };
40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationContainerView.h; sourceTree = "<group>"; };
40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationContainerView.m; sourceTree = "<group>"; };
+ 40F8876F1D7A1DB8008ECB67 /* MGLGeoJSONSource_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLGeoJSONSource_Private.h; sourceTree = "<group>"; };
40FDA7691CCAAA6800442548 /* MBXAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBXAnnotationView.h; sourceTree = "<group>"; };
40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = "<group>"; };
554180411D2E97DE00012372 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
@@ -810,11 +809,10 @@
350098B91D480108004B2AF0 /* MGLVectorSource.h */,
350098BA1D480108004B2AF0 /* MGLVectorSource.mm */,
3566C7641D4A77BA008152BC /* MGLGeoJSONSource.h */,
+ 40F8876F1D7A1DB8008ECB67 /* MGLGeoJSONSource_Private.h */,
3566C7651D4A77BA008152BC /* MGLGeoJSONSource.mm */,
3566C76A1D4A8DFA008152BC /* MGLRasterSource.h */,
3566C76B1D4A8DFA008152BC /* MGLRasterSource.mm */,
- 35E751DA1D76BE9800DFF553 /* MGLGeoJSONOptions.h */,
- 35E751DB1D76BE9800DFF553 /* MGLGeoJSONOptions.m */,
);
name = Sources;
sourceTree = "<group>";
@@ -888,6 +886,7 @@
children = (
3575798F1D513EF1000B822E /* Layers */,
35B8E08B1D6C8B5100E768D2 /* MGLFilterTests.mm */,
+ 40CFA64E1D78754A008103BD /* Sources */,
);
name = Styling;
sourceTree = "<group>";
@@ -926,6 +925,14 @@
name = Playground;
sourceTree = "<group>";
};
+ 40CFA64E1D78754A008103BD /* Sources */ = {
+ isa = PBXGroup;
+ children = (
+ 40CFA6501D787579008103BD /* MGLGeoJSONSourceTests.mm */,
+ );
+ name = Sources;
+ sourceTree = "<group>";
+ };
DA1DC9411CB6C1C2006E619F = {
isa = PBXGroup;
children = (
@@ -1376,8 +1383,8 @@
35D13AB71D3D15E300AFB4E0 /* MGLStyleLayer.h in Headers */,
354D42DC1D4919F900F400A1 /* NSValue+MGLStyleAttributeAdditions_Private.h in Headers */,
DA88488E1CBB047F00AB86E3 /* reachability.h in Headers */,
+ 40F887701D7A1E58008ECB67 /* MGLGeoJSONSource_Private.h in Headers */,
350098DC1D484E60004B2AF0 /* NSValue+MGLStyleAttributeAdditions.h in Headers */,
- 35E751DC1D76BE9800DFF553 /* MGLGeoJSONOptions.h in Headers */,
DA8848231CBAFA6200AB86E3 /* MGLOfflineStorage_Private.h in Headers */,
404326891D5B9B27007111BD /* MGLAnnotationContainerView_Private.h in Headers */,
DA88483B1CBAFB8500AB86E3 /* MGLCalloutView.h in Headers */,
@@ -1493,7 +1500,6 @@
3566C7721D4A9198008152BC /* MGLSource_Private.h in Headers */,
353933FF1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */,
DABFB8661CBE99E500D62B32 /* MGLPointAnnotation.h in Headers */,
- 35E751DD1D76BE9800DFF553 /* MGLGeoJSONOptions.h in Headers */,
35599DF11D46F3A60048254D /* MGLStyleAttributeValue.h in Headers */,
DABFB8621CBE99E500D62B32 /* MGLOfflinePack.h in Headers */,
DAD1656D1CF41981001FF4B9 /* MGLFeature.h in Headers */,
@@ -1523,6 +1529,7 @@
353933F31D3FB753003F57D7 /* MGLCircleStyleLayer.h in Headers */,
3593E5271D529EDC006D9365 /* UIColor+MGLStyleAttributeAdditions_Private.h in Headers */,
3538AA1E1D542239008EC33D /* MGLBaseStyleLayer.h in Headers */,
+ 40F887711D7A1E59008ECB67 /* MGLGeoJSONSource_Private.h in Headers */,
DABFB8631CBE99E500D62B32 /* MGLOfflineRegion.h in Headers */,
DA35A2B21CCA141D00E826B2 /* MGLCompassDirectionFormatter.h in Headers */,
DABFB8731CBE9A9900D62B32 /* Mapbox.h in Headers */,
@@ -1856,6 +1863,7 @@
357579851D502AF5000B822E /* MGLSymbolStyleLayerTests.m in Sources */,
357579871D502AFE000B822E /* MGLLineStyleLayerTests.m in Sources */,
357579891D502B06000B822E /* MGLCircleStyleLayerTests.m in Sources */,
+ 40CFA6511D7875BB008103BD /* MGLGeoJSONSourceTests.mm in Sources */,
DA35A2C51CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m in Sources */,
35B8E08C1D6C8B5100E768D2 /* MGLFilterTests.mm in Sources */,
3575798B1D502B0C000B822E /* MGLBackgroundStyleLayerTests.m in Sources */,
@@ -1917,7 +1925,6 @@
DA88481F1CBAFA6200AB86E3 /* MGLMultiPoint.mm in Sources */,
DA88482B1CBAFA6200AB86E3 /* MGLTypes.m in Sources */,
4018B1C71CDC287F00F666AF /* MGLAnnotationView.mm in Sources */,
- 35E751DE1D76BE9800DFF553 /* MGLGeoJSONOptions.m in Sources */,
DA88481D1CBAFA6200AB86E3 /* MGLMapCamera.mm in Sources */,
DA8848261CBAFA6200AB86E3 /* MGLPolygon.mm in Sources */,
35B82BFA1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */,
@@ -1986,7 +1993,6 @@
DAA4E4301CBB730400178DFB /* MGLLocationManager.m in Sources */,
DAA4E4321CBB730400178DFB /* MGLMapView.mm in Sources */,
DAA4E41E1CBB730400178DFB /* MGLMapCamera.mm in Sources */,
- 35E751DF1D76BE9800DFF553 /* MGLGeoJSONOptions.m in Sources */,
4018B1C81CDC287F00F666AF /* MGLAnnotationView.mm in Sources */,
DAA4E4341CBB730400178DFB /* MGLFaux3DUserLocationAnnotationView.m in Sources */,
35B82BFB1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */,
diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h
index 06fdbe20f0..24925d169c 100644
--- a/platform/ios/src/Mapbox.h
+++ b/platform/ios/src/Mapbox.h
@@ -43,7 +43,6 @@ FOUNDATION_EXPORT const unsigned char MapboxVersionString[];
#import "MGLSource.h"
#import "MGLVectorSource.h"
#import "MGLGeoJSONSource.h"
-#import "MGLGeoJSONOptions.h"
#import "MGLRasterSource.h"
#import "MGLTilePyramidOfflineRegion.h"
#import "MGLTypes.h"
diff --git a/platform/ios/test/MGLGeoJSONSourceTests.mm b/platform/ios/test/MGLGeoJSONSourceTests.mm
new file mode 100644
index 0000000000..76353dc76b
--- /dev/null
+++ b/platform/ios/test/MGLGeoJSONSourceTests.mm
@@ -0,0 +1,39 @@
+#import <XCTest/XCTest.h>
+
+#import <Mapbox/Mapbox.h>
+#import "MGLGeoJSONSource_Private.h"
+
+#include <mbgl/style/sources/geojson_source.hpp>
+
+@interface MGLGeoJSONSourceTests : XCTestCase
+
+@end
+
+@implementation MGLGeoJSONSourceTests
+
+- (void)testMGLGeoJSONSourceWithOptions {
+ NSURL *url = [NSURL URLWithString:@"http://www.mapbox.com/source"];
+
+ NSDictionary *options = @{MGLGeoJSONClusterOption: @(YES),
+ MGLGeoJSONClusterRadiusOption: @42,
+ MGLGeoJSONClusterMaximumZoomLevelOption: @98,
+ MGLGeoJSONMaximumZoomLevelOption: @99,
+ MGLGeoJSONBufferOption: @1976,
+ MGLGeoJSONToleranceOption: @0.42};
+ MGLGeoJSONSource *source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"source-id" URL:url options:options];
+
+ auto mbglOptions = [source geoJSONOptions];
+ XCTAssertTrue(mbglOptions.cluster);
+ XCTAssertEqual(mbglOptions.clusterRadius, 42);
+ XCTAssertEqual(mbglOptions.clusterMaxZoom, 98);
+ XCTAssertEqual(mbglOptions.maxzoom, 99);
+ XCTAssertEqual(mbglOptions.buffer, 1976);
+ XCTAssertEqual(mbglOptions.tolerance, 0.42);
+
+ // when the supplied option cluster value is not of the correct type
+ options = @{MGLGeoJSONClusterOption: @"number 1"};
+ source = [[MGLGeoJSONSource alloc] initWithSourceIdentifier:@"source-id" URL:url options:options];
+ XCTAssertThrows([source geoJSONOptions]);
+}
+
+@end