Skip to content

Commit

Permalink
Naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Oct 29, 2018
1 parent 48252bd commit de5e5bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions MapboxCoreNavigation/OfflineDirections.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public protocol OfflineRoutingProtocol {
- parameter accessToken: A Mapbox [access token](https://www.mapbox.com/help/define-access-token/). If an access token is not specified when initializing the directions object, it should be specified in the `MGLMapboxAccessToken` key in the main application bundle’s Info.plist.
- parameter host: An optional hostname to the server API. The [Mapbox Directions API](https://www.mapbox.com/api-documentation/?language=Swift#directions) endpoint is used by default.
*/
init(tilesPath: URL, translationsPath: URL, accessToken: String?, host: String?, completionHandler: @escaping OfflineDirectionsCompletionHandler)
init(tilesURL: URL, translationsURL: URL, accessToken: String?, host: String?, completionHandler: @escaping OfflineDirectionsCompletionHandler)

/**
Begins asynchronously calculating the route or routes using the given options and delivers the results to a closure.
Expand All @@ -59,16 +59,16 @@ public protocol OfflineRoutingProtocol {
func calculate(_ options: RouteOptions, offline: Bool, completionHandler: @escaping Directions.RouteCompletionHandler)
}

@objc(MBMapboxOfflineDirections)
public class MapboxOfflineDirections: Directions, OfflineRoutingProtocol {
@objc(MBNavigationDirections)
public class NavigationDirections: Directions, OfflineRoutingProtocol {

public required init(tilesPath: URL, translationsPath: URL, accessToken: String?, host: String? = nil, completionHandler: @escaping OfflineDirectionsCompletionHandler) {
public required init(tilesURL: URL, translationsURL: URL, accessToken: String?, host: String? = nil, completionHandler: @escaping OfflineDirectionsCompletionHandler) {

super.init(accessToken: accessToken, host: host)

OfflineDirectionsConstants.serialQueue.sync {
let tilesPath = tilesPath.absoluteString.replacingOccurrences(of: "file://", with: "")
let translationsPath = translationsPath.absoluteString.replacingOccurrences(of: "file://", with: "")
let tilesPath = tilesURL.absoluteString.replacingOccurrences(of: "file://", with: "")
let translationsPath = translationsURL.absoluteString.replacingOccurrences(of: "file://", with: "")
let tileCount = self.navigator.configureRouter(forTilesPath: tilesPath, translationsPath: translationsPath)

DispatchQueue.main.async {
Expand Down
13 changes: 7 additions & 6 deletions MapboxCoreNavigationTests/OfflineRoutingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import XCTest
import MapboxDirections
@testable import MapboxCoreNavigation


class OfflineRoutingTests: XCTestCase {

func testOfflineDirections() {
let bundle = Bundle(for: OfflineRoutingTests.self)
let tilesPath = URL(fileURLWithPath: bundle.bundlePath.appending("/routing/liechtenstein"))
let translationsPath = URL(fileURLWithPath: bundle.bundlePath.appending("/translations"))
let tilesURL = URL(fileURLWithPath: bundle.bundlePath.appending("/routing/liechtenstein"))
let translationsURL = URL(fileURLWithPath: bundle.bundlePath.appending("/translations"))

let setupExpectation = expectation(description: "Set up offline routing")

let directions = MapboxOfflineDirections(tilesPath: tilesPath, translationsPath: translationsPath, accessToken: "foo") { (numberOfTiles) in
let directions = NavigationDirections(tilesURL: tilesURL, translationsURL: translationsURL, accessToken: "foo") { (numberOfTiles) in
XCTAssertEqual(numberOfTiles, 5)
setupExpectation.fulfill()
}
Expand Down Expand Up @@ -42,12 +43,12 @@ class OfflineRoutingTests: XCTestCase {

func testOfflineDirectionsError() {
let bundle = Bundle(for: OfflineRoutingTests.self)
let tilesPath = URL(fileURLWithPath: bundle.bundlePath).appendingPathComponent("/routing/liechtenstein")
let translationsPath = URL(fileURLWithPath: bundle.bundlePath).appendingPathComponent("/translations")
let tilesURL = URL(fileURLWithPath: bundle.bundlePath).appendingPathComponent("/routing/liechtenstein")
let translationsURL = URL(fileURLWithPath: bundle.bundlePath).appendingPathComponent("/translations")

let setupExpectation = expectation(description: "Set up offline routing")

let directions = MapboxOfflineDirections(tilesPath: tilesPath, translationsPath: translationsPath, accessToken: "foo") { (numberOfTiles) in
let directions = NavigationDirections(tilesURL: tilesURL, translationsURL: translationsURL, accessToken: "foo") { (numberOfTiles) in
XCTAssertEqual(numberOfTiles, 5)
setupExpectation.fulfill()
}
Expand Down

0 comments on commit de5e5bf

Please sign in to comment.