Skip to content

Commit

Permalink
Rename to MapboxDirections and add support for Swift Package Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Mar 23, 2019
1 parent ff2a458 commit 7833e8a
Show file tree
Hide file tree
Showing 73 changed files with 179 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Carthage/Build
Carthage/Checkouts
/build
/documentation
./build
File renamed without changes.
84 changes: 18 additions & 66 deletions MapboxDirections.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

38 changes: 0 additions & 38 deletions MapboxDirections/MBAttribute.h

This file was deleted.

35 changes: 0 additions & 35 deletions MapboxDirections/MBLaneIndication.h

This file was deleted.

40 changes: 0 additions & 40 deletions MapboxDirections/MBRoadClasses.h

This file was deleted.

38 changes: 0 additions & 38 deletions MapboxDirections/MBRouteOptions.h

This file was deleted.

7 changes: 0 additions & 7 deletions MapboxDirections/MBRouteOptions.m

This file was deleted.

16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "Polyline",
"repositoryURL": "/Users/fredrik/Workspace/mapbox/Polyline",
"state": {
"branch": "fred/spm4.2",
"revision": "4b4b4957549f7d0f1d59e6b3c662234402717de9",
"version": null
}
}
]
},
"version": 1
}
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:4.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "MapboxDirections",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "MapboxDirections",
targets: ["MapboxDirections"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "../Polyline", .branch("fred/spm4.2"))
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "MapboxDirections",
dependencies: ["Polyline"]),
.testTarget(
name: "MapboxDirectionsTests",
dependencies: ["MapboxDirections"]),
]
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import Foundation

public typealias AttributeOptions = MBAttributeOptions
public struct AttributeOptions : OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
self.rawValue = rawValue
}

static let distance = AttributeOptions(rawValue: 1 << 1)
static let expectedTravelTime = AttributeOptions(rawValue: 1 << 2)
static let speed = AttributeOptions(rawValue: 1 << 3)
static let congestionLevel = AttributeOptions(rawValue: 1 << 4)
}

extension AttributeOptions: CustomStringConvertible {
/**
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation


typealias JSONDictionary = [String: Any]

/// Indicates that an error occurred in MapboxDirections.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
import Polyline
import CoreLocation


/**
Maximum length of an HTTP request URL for the purposes of switching from GET to
Expand Down Expand Up @@ -230,7 +232,7 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {
- parameter waypoints: An array of `Waypoint` objects representing locations that the route should visit in chronological order. The array should contain at least two waypoints (the source and destination) and at most 25 waypoints. (Some profiles, such as `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, [may have lower limits](https://docs.mapbox.com/api/navigation/#directions).)
- parameter profileIdentifier: A string specifying the primary mode of transportation for the routes. This parameter, if set, should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. `MBDirectionsProfileIdentifierAutomobile` is used by default.
*/
@objc required public init(waypoints: [Waypoint], profileIdentifier: MBDirectionsProfileIdentifier? = nil) {
required public init(waypoints: [Waypoint], profileIdentifier: DirectionsProfileIdentifier? = nil) {
self.waypoints = waypoints
self.profileIdentifier = profileIdentifier ?? .automobile
}
Expand Down Expand Up @@ -298,7 +300,7 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {
guard let profileIdentifier = decoder.decodeObject(of: NSString.self, forKey: "profileIdentifier") as String? else {
return nil
}
self.profileIdentifier = MBDirectionsProfileIdentifier(rawValue: profileIdentifier)
self.profileIdentifier = DirectionsProfileIdentifier(rawValue: profileIdentifier)!

includesSteps = decoder.decodeBool(forKey: "includesSteps")

Expand Down Expand Up @@ -382,7 +384,7 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {

This property should be set to `MBDirectionsProfileIdentifierAutomobile`, `MBDirectionsProfileIdentifierAutomobileAvoidingTraffic`, `MBDirectionsProfileIdentifierCycling`, or `MBDirectionsProfileIdentifierWalking`. The default value of this property is `MBDirectionsProfileIdentifierAutomobile`, which specifies driving directions.
*/
@objc open var profileIdentifier: MBDirectionsProfileIdentifier
open var profileIdentifier: DirectionsProfileIdentifier

/**
A Boolean value indicating whether `MBRouteStep` objects should be included in the response.
Expand Down Expand Up @@ -418,7 +420,7 @@ open class DirectionsOptions: NSObject, NSSecureCoding, NSCopying {

By default, no attribute options are specified. It is recommended that `routeShapeResolution` be set to `.full`.
*/
@objc open var attributeOptions: AttributeOptions = []
open var attributeOptions: AttributeOptions = []

/**
The locale in which the route’s instructions are written.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Foundation
import Polyline
import CoreLocation


/**
A `DirectionsResult` represents a result returned from either the Mapbox Directions service.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Foundation
import CoreLocation


/**
A single cross street along a step.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public class Lane: NSObject, NSSecureCoding {
/**
The lane indications specifying the maneuvers that may be executed from the lane.
*/
@objc public let indications: LaneIndication
public let indications: LaneIndication

/**
Initializes a new `Lane` using the given lane indications.
*/
@objc public init(indications: LaneIndication) {
public init(indications: LaneIndication) {
self.indications = indications
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import Foundation

public typealias LaneIndication = MBLaneIndication

public struct LaneIndication : OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
self.rawValue = rawValue
}

static let sharpRight = LaneIndication(rawValue: 1 << 1)
static let right = LaneIndication(rawValue: 1 << 2)
static let slightRight = LaneIndication(rawValue: 1 << 3)
static let straightAhead = LaneIndication(rawValue: 1 << 4)
static let slightLeft = LaneIndication(rawValue: 1 << 5)
static let left = LaneIndication(rawValue: 1 << 6)
static let sharpLeft = LaneIndication(rawValue: 1 << 7)
static let uTurn = LaneIndication(rawValue: 1 << 8)
}

extension LaneIndication: CustomStringConvertible {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation


/**
A component that represents a lane representation of an instruction.
*/
Expand All @@ -9,7 +12,7 @@ open class LaneIndicationComponent: NSObject, ComponentRepresentable {

If the value is `[LaneIndication.left", LaneIndication.straightAhead]`, the driver can go left or straight ahead from that lane. This is only set when the `component` is a `lane`.
*/
@objc public var indications: LaneIndication
public var indications: LaneIndication

/**
The boolean that indicates whether the lane can be used to complete the maneuver.
Expand All @@ -26,7 +29,7 @@ open class LaneIndicationComponent: NSObject, ComponentRepresentable {
- parameter indications: The directions to go from a lane component.
- parameter isUsable: The flag to indicate that the upcoming maneuver can be completed with a lane component.
*/
@objc public init(indications: LaneIndication, isUsable: Bool) {
public init(indications: LaneIndication, isUsable: Bool) {
self.indications = indications
self.isUsable = isUsable
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import Foundation

public typealias RoadClasses = MBRoadClasses
//public typealias RoadClasses = MBRoadClasses

public struct RoadClasses : OptionSet {
public let rawValue: Int

public init(rawValue: Int) {
self.rawValue = rawValue
}

static let toll = RoadClasses(rawValue: 1 << 1)
static let restricted = RoadClasses(rawValue: 1 << 2)
static let motorway = RoadClasses(rawValue: 1 << 3)
static let ferry = RoadClasses(rawValue: 1 << 4)
static let tunnel = RoadClasses(rawValue: 1 << 5)
}

extension RoadClasses: CustomStringConvertible {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Foundation
import CoreLocation
import Polyline


/**
A `Route` object defines a single route that the user can follow to visit a series of waypoints in order. The route object includes information about the route, such as its distance and expected travel time. Depending on the criteria used to calculate the route, the route object may also include detailed turn-by-turn instructions.

Expand Down
Loading

0 comments on commit 7833e8a

Please sign in to comment.