Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose tilecover experimental API (#1469)
* Expose tilecover experimental API * Use tilecover api in debug map example * Add integration tests for tileCover * fix spaces * Update Changelog * review fixes * fix testplan * add test for tileCover with the default parameter
- Loading branch information
1 parent
c16081e
commit ee74972
Showing
11 changed files
with
134 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
Apps/Examples/Examples/Extensions/UIViewController+Children.swift
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
Apps/Examples/Examples/Extensions/UIViewController+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import UIKit | ||
|
||
extension UIViewController { | ||
internal func addChildViewController(_ child: UIViewController) { | ||
addChild(child) | ||
view.addSubview(child.view) | ||
child.didMove(toParent: self) | ||
} | ||
|
||
internal func remove() { | ||
guard parent != nil else { | ||
return | ||
} | ||
|
||
willMove(toParent: nil) | ||
view.removeFromSuperview() | ||
removeFromParent() | ||
} | ||
|
||
// Present an alert with a given title and message. | ||
func showAlert(withTitle title: String, and message: String) { | ||
let alertController = UIAlertController(title: title, | ||
message: message, | ||
preferredStyle: .alert) | ||
|
||
alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) | ||
|
||
present(alertController, animated: true, completion: nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import MapboxCoreMaps | ||
|
||
/// Various options needed for tile cover. | ||
@_spi(Experimental) | ||
public struct TileCoverOptions { | ||
/// Tile size of the source. Defaults to 512. | ||
public var tileSize: UInt16? | ||
|
||
/// Min zoom defined in the source between range [0, 22]. | ||
/// if not provided or is out of range, defaults to 0. | ||
public var minZoom: UInt8? | ||
|
||
/// Max zoom defined in the source between range [0, 22]. | ||
/// Should be greater than or equal to minZoom. | ||
/// If not provided or is out of range, defaults to 22. | ||
public var maxZoom: UInt8? | ||
|
||
/// Whether to round zoom values when calculating tilecover. | ||
/// Set this to true for raster and raster-dem sources. | ||
/// If not specified, defaults to false. | ||
public var roundZoom: Bool? | ||
|
||
/// Creates the TileCoverOptions. | ||
public init( | ||
tileSize: UInt16? = nil, | ||
minZoom: UInt8? = nil, | ||
maxZoom: UInt8? = nil, | ||
roundZoom: Bool? = nil | ||
) { | ||
self.tileSize = tileSize | ||
self.minZoom = minZoom | ||
self.maxZoom = maxZoom | ||
self.roundZoom = roundZoom | ||
} | ||
} | ||
|
||
extension MapboxCoreMaps.TileCoverOptions { | ||
internal convenience init(_ options: TileCoverOptions) { | ||
self.init( | ||
__tileSize: options.tileSize.map { NSNumber(value: $0) }, | ||
minZoom: options.minZoom.map { NSNumber(value: $0) }, | ||
maxZoom: options.maxZoom.map { NSNumber(value: $0) }, | ||
roundZoom: options.roundZoom.map { NSNumber(value: $0) }) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Tests/MapboxMapsTests/Integration Tests/TileCoverIntegrationTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import XCTest | ||
@_spi(Experimental) import MapboxMaps | ||
|
||
class TileCoverIntegrationTests: MapViewIntegrationTestCase { | ||
func testTileCover() { | ||
mapView.mapboxMap.setCamera(to: CameraOptions(zoom: 5.5)) | ||
let tileIds = mapView.mapboxMap.tileCover(for: TileCoverOptions(tileSize: 512, minZoom: 0, maxZoom: 22, roundZoom: false)) | ||
XCTAssertFalse(tileIds.isEmpty) | ||
for tileId in tileIds { | ||
XCTAssertEqual(tileId.z, 5) // sanity check | ||
} | ||
} | ||
|
||
func testTileCoverDefaultParameters() throws { | ||
throw XCTSkip("Default value resolution will be fixed in MAPSNAT-1024") | ||
mapView.mapboxMap.setCamera(to: CameraOptions(zoom: 5.5)) | ||
let tileIds = mapView.mapboxMap.tileCover(for: TileCoverOptions()) | ||
XCTAssertFalse(tileIds.isEmpty) | ||
for tileId in tileIds { | ||
XCTAssertEqual(tileId.z, 5) // sanity check | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters