diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2018-01-25 10:46:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 10:46:27 -0800 |
commit | b6747a84f4ba6bd48ab2d461e04cffa7fc8d5348 (patch) | |
tree | e01efa0e57e6dc5a0a55db2f68bc964cb6fb1606 /platform/darwin/test | |
parent | a4546a84de28cfddfcb1e5a4ba8b0516a4b4dfa4 (diff) | |
download | qtlocation-mapboxgl-b6747a84f4ba6bd48ab2d461e04cffa7fc8d5348.tar.gz |
[ios, macos] Hook up hillshade style layers, raster DEM sources to iOS/macOS (#11036)
* [ios, macos] Finished implementing MGLHillshadeStyleLayer
* [macos] Added icon for hillshade layer
Also set the background layer icon to mirror in right-to-left locales.
* [ios, macos] Implemented raster DEM source
* [macos] Added Enhance Terrain debugging command
* [ios, macos] Simplified raster DEM source example
Diffstat (limited to 'platform/darwin/test')
-rw-r--r-- | platform/darwin/test/MGLDocumentationExampleTests.swift | 47 | ||||
-rw-r--r-- | platform/darwin/test/MGLHillshadeStyleLayerTests.mm | 18 | ||||
-rw-r--r-- | platform/darwin/test/MGLStyleLayerTests.mm.ejs | 2 |
3 files changed, 48 insertions, 19 deletions
diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift index d3e2bf91f2..9bf9924869 100644 --- a/platform/darwin/test/MGLDocumentationExampleTests.swift +++ b/platform/darwin/test/MGLDocumentationExampleTests.swift @@ -88,6 +88,26 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { XCTAssertNotNil(mapView.style?.source(withIdentifier: "clouds")) } + + func testMGLRasterDEMSource() { + // We want to use mapbox.terrain-rgb in the example, but using a mapbox: + // URL requires setting an access token. So this identically named + // subclass of MGLRasterDEMSource swaps in a nonexistent URL. + class MGLRasterDEMSource: Mapbox.MGLRasterDEMSource { + override init(identifier: String, configurationURL: URL, tileSize: CGFloat = 256) { + let bogusURL = URL(string: "https://example.com/raster-rgb.json")! + super.init(identifier: identifier, configurationURL: bogusURL, tileSize: tileSize) + } + } + + //#-example-code + let terrainRGBURL = URL(string: "mapbox://mapbox.terrain-rgb")! + let source = MGLRasterDEMSource(identifier: "hills", configurationURL: terrainRGBURL) + mapView.style?.addSource(source) + //#-end-example-code + + XCTAssertNotNil(mapView.style?.source(withIdentifier: "hills")) + } func testMGLVectorSource() { //#-example-code @@ -256,6 +276,33 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { XCTAssertNotNil(mapView.style?.layer(withIdentifier: "clouds")) } + func testMGLHillshadeStyleLayer() { + let source = MGLRasterDEMSource(identifier: "dem", tileURLTemplates: ["https://example.com/raster-rgb/{z}/{x}/{y}.png"], options: [ + .minimumZoomLevel: 9, + .maximumZoomLevel: 16, + .tileSize: 256, + .attributionInfos: [ + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + ] + ]) + mapView.style?.addSource(source) + + let canals = MGLVectorSource(identifier: "canals", configurationURL: URL(string: "https://example.com/style.json")!) + mapView.style?.addSource(canals) + let canalShadowLayer = MGLLineStyleLayer(identifier: "waterway-river-canal-shadow", source: canals) + mapView.style?.addLayer(canalShadowLayer) + + //#-example-code + let layer = MGLHillshadeStyleLayer(identifier: "hills", source: source) + layer.hillshadeExaggeration = NSExpression(forConstantValue: 0.6) + if let canalShadowLayer = mapView.style?.layer(withIdentifier: "waterway-river-canal-shadow") { + mapView.style?.insertLayer(layer, below: canalShadowLayer) + } + //#-end-example-code + + XCTAssertNotNil(mapView.style?.layer(withIdentifier: "hills")) + } + func testMGLVectorStyleLayer$predicate() { let terrain = MGLVectorSource(identifier: "terrain", configurationURL: URL(string: "https://example.com/style.json")!) mapView.style?.addSource(terrain) diff --git a/platform/darwin/test/MGLHillshadeStyleLayerTests.mm b/platform/darwin/test/MGLHillshadeStyleLayerTests.mm index 8f37b52790..b0b7ddd5ee 100644 --- a/platform/darwin/test/MGLHillshadeStyleLayerTests.mm +++ b/platform/darwin/test/MGLHillshadeStyleLayerTests.mm @@ -18,24 +18,6 @@ return @"hillshade"; } -- (void)testPredicates { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; - MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; - MGLHillshadeStyleLayer *layer = [[MGLHillshadeStyleLayer alloc] initWithIdentifier:@"layerID" source:source]; - - XCTAssertNil(layer.sourceLayerIdentifier); - layer.sourceLayerIdentifier = @"layerID"; - XCTAssertEqualObjects(layer.sourceLayerIdentifier, @"layerID"); - layer.sourceLayerIdentifier = nil; - XCTAssertNil(layer.sourceLayerIdentifier); - - XCTAssertNil(layer.predicate); - layer.predicate = [NSPredicate predicateWithValue:NO]; - XCTAssertEqualObjects(layer.predicate, [NSPredicate predicateWithValue:NO]); - layer.predicate = nil; - XCTAssertNil(layer.predicate); -} - - (void)testProperties { MGLPointFeature *feature = [[MGLPointFeature alloc] init]; MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs index 0487066255..e26c63e662 100644 --- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs +++ b/platform/darwin/test/MGLStyleLayerTests.mm.ejs @@ -23,7 +23,7 @@ return @"<%- type %>"; } -<% if (type !== 'background' && type !== 'raster') { -%> +<% if (type !== 'background' && type !== 'raster' && type !== 'hillshade') { -%> - (void)testPredicates { MGLPointFeature *feature = [[MGLPointFeature alloc] init]; MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"sourceID" shape:feature options:nil]; |