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.
40 lines
1.5 KiB
Plaintext
40 lines
1.5 KiB
Plaintext
#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
|