-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vk-2926-tilestore-config: replaced TileStoreLocation with TileStoreCo…
…nfiguration. Added code docs. Added config for PassiveLocationDataSource.
- Loading branch information
Showing
12 changed files
with
115 additions
and
90 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
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
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,86 @@ | ||
|
||
import Foundation | ||
import MapboxCommon | ||
|
||
/** | ||
Describes `TileStore` setup. | ||
This struct encapsulates logic for handling `default` and `custom` paths as well as providing corresponding `TileStore`s. | ||
It also covers differences between tile storages for Map and Navigation data. Tupically, you won't need to configure these and rely on defaults, unless you provide pre-downloaded data withing your app in which case you'll need `custom()` path to point to your data. | ||
*/ | ||
public struct TileStoreConfiguration { | ||
/** | ||
Describes filesystem location for tile storage folder | ||
*/ | ||
public enum Location: RawRepresentable { | ||
/** | ||
Encapsulated default location. | ||
`rawValue` for this case will return `nil` | ||
*/ | ||
case `default` | ||
/** | ||
User-provided path to tile storage folder | ||
*/ | ||
case custom(URL) | ||
|
||
public init?(rawValue: URL?) { | ||
self = rawValue.map { .custom($0) } ?? .default | ||
} | ||
|
||
/** | ||
Corresponding URL path | ||
`default` location is interpreted as `nil`. | ||
*/ | ||
public var rawValue: URL? { | ||
switch self { | ||
case .default: | ||
return nil | ||
case .custom(let url): | ||
return url | ||
} | ||
} | ||
/** | ||
A `TileStore` instance, configured for current location. | ||
*/ | ||
public var tileStore: TileStore { | ||
switch self { | ||
case .default: | ||
return TileStore.getInstance() | ||
case .custom(let url): | ||
return TileStore.getInstanceForPath(url.path) | ||
} | ||
} | ||
} | ||
|
||
/** | ||
Location of Navigator tiles data | ||
*/ | ||
public let navigatorLocation: Location | ||
/** | ||
Location of Map tiles data | ||
*/ | ||
public let mapLocation: Location? | ||
|
||
/** | ||
Tile data will be stored at default SDK location | ||
*/ | ||
public static var `default`: Self { | ||
.init(navigatorLocation: .default, mapLocation: .default) | ||
} | ||
/** | ||
Custom path to a folder, where tiles data will be stored | ||
*/ | ||
public static func custom(_ url: URL) -> Self { | ||
.init(navigatorLocation: .custom(url), mapLocation: .custom(url)) | ||
} | ||
/** | ||
:nodoc: | ||
Option to configure Map and Navigation tiles to be stored separately. You should not use this option unless you know what you are doing. | ||
*/ | ||
public static func isolated(navigationLocation: Location, mapLocation: Location?) -> Self { | ||
.init(navigatorLocation: navigationLocation, mapLocation: mapLocation) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.