Skip to content

Commit

Permalink
Profile identifiers now bridges to Objective-C
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Jan 18, 2017
1 parent 581f246 commit 26d2fdc
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 36 deletions.
20 changes: 20 additions & 0 deletions MapboxDirections.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
358D48811E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
358D48821E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
358D48831E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
358D48841E2EAB2500F32A65 /* MBRouteOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 358D48801E2EAB2500F32A65 /* MBRouteOptions.h */; settings = {ATTRIBUTES = (Public, ); }; };
358D48861E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; };
358D48871E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; };
358D48881E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; };
358D48891E2EAB4500F32A65 /* MBRouteOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 358D48851E2EAB4500F32A65 /* MBRouteOptions.m */; };
C547EC691DB59F8F009817F3 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; };
C547EC6A1DB59F90009817F3 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; };
C547EC6B1DB59F91009817F3 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; };
Expand Down Expand Up @@ -116,6 +124,8 @@
C57B2E951DB8171300E9123A /* MBLaneIndication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBLaneIndication.h; sourceTree = "<group>"; };
C57D55001DB5669600B94B74 /* MBIntersection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBIntersection.swift; sourceTree = "<group>"; };
C57D55071DB58C0200B94B74 /* MBLane.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBLane.swift; sourceTree = "<group>"; };
358D48801E2EAB2500F32A65 /* MBRouteOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBRouteOptions.h; sourceTree = "<group>"; };
358D48851E2EAB4500F32A65 /* MBRouteOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBRouteOptions.m; sourceTree = "<group>"; };
DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MapboxDirections.framework; sourceTree = BUILT_PRODUCTS_DIR; };
DA1A10B81D00F8FF009F82FA /* MapboxDirectionsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MapboxDirectionsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
DA1A10D51D0101ED009F82FA /* MapboxDirections.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MapboxDirections.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -227,6 +237,8 @@
DD6254731AE70CB700017857 /* MBDirections.swift */,
DAC05F171CFC075300FA0071 /* MBRoute.swift */,
DAC05F191CFC077C00FA0071 /* MBRouteLeg.swift */,
358D48801E2EAB2500F32A65 /* MBRouteOptions.h */,
358D48851E2EAB4500F32A65 /* MBRouteOptions.m */,
DA2E03EA1CB0E13D00D1269A /* MBRouteOptions.swift */,
DA2E03E81CB0E0B000D1269A /* MBRouteStep.swift */,
C57D55001DB5669600B94B74 /* MBIntersection.swift */,
Expand Down Expand Up @@ -333,6 +345,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
358D48821E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA1A10C61D00F969009F82FA /* MapboxDirections.h in Headers */,
C57B2E971DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
Expand All @@ -342,6 +355,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
358D48831E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA1A10EC1D010247009F82FA /* MapboxDirections.h in Headers */,
C57B2E981DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
Expand All @@ -351,6 +365,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
358D48841E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA1A11031D0103A3009F82FA /* MapboxDirections.h in Headers */,
C57B2E991DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
Expand All @@ -360,6 +375,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
358D48811E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA6C9D8B1CAE442B00094FBC /* MapboxDirections.h in Headers */,
C57B2E961DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
Expand Down Expand Up @@ -629,6 +645,7 @@
buildActionMask = 2147483647;
files = (
DA1A10C91D00F969009F82FA /* MBRouteLeg.swift in Sources */,
358D48871E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DA1A10CC1D00F969009F82FA /* MBWaypoint.swift in Sources */,
DA1A10CA1D00F969009F82FA /* MBRouteOptions.swift in Sources */,
DA1A10C81D00F969009F82FA /* MBRoute.swift in Sources */,
Expand Down Expand Up @@ -657,6 +674,7 @@
buildActionMask = 2147483647;
files = (
DA1A10EF1D010247009F82FA /* MBRouteLeg.swift in Sources */,
358D48881E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DA1A10F21D010247009F82FA /* MBWaypoint.swift in Sources */,
DA1A10F01D010247009F82FA /* MBRouteOptions.swift in Sources */,
DA1A10EE1D010247009F82FA /* MBRoute.swift in Sources */,
Expand Down Expand Up @@ -685,6 +703,7 @@
buildActionMask = 2147483647;
files = (
DA1A11061D0103A3009F82FA /* MBRouteLeg.swift in Sources */,
358D48891E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DA1A11091D0103A3009F82FA /* MBWaypoint.swift in Sources */,
DA1A11071D0103A3009F82FA /* MBRouteOptions.swift in Sources */,
DA1A11051D0103A3009F82FA /* MBRoute.swift in Sources */,
Expand All @@ -701,6 +720,7 @@
buildActionMask = 2147483647;
files = (
DA2E03EB1CB0E13D00D1269A /* MBRouteOptions.swift in Sources */,
358D48861E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DAC05F161CFBFAC400FA0071 /* MBWaypoint.swift in Sources */,
C57D55081DB58C0200B94B74 /* MBLane.swift in Sources */,
DAC05F181CFC075300FA0071 /* MBRoute.swift in Sources */,
Expand Down
35 changes: 35 additions & 0 deletions MapboxDirections/MBRouteOptions.h
@@ -0,0 +1,35 @@
#import <Foundation/Foundation.h>

#pragma mark - Specifying the Routing Profile

typedef NSString * MBDirectionsProfileIdentifier NS_EXTENSIBLE_STRING_ENUM;

/**
The returned directions are appropriate for driving or riding a car, truck, or motorcycle.
This profile prioritizes fast routes by preferring high-speed roads like highways. A driving route may use a ferry where necessary.
*/
extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobile;

/**
The returned directions are appropriate for driving or riding a car, truck, or motorcycle.
This profile avoids traffic congestion based on current traffic data. A driving route may use a ferry where necessary.
- experiment: This profile is experimental. Where traffic data is absent, this profile prefers high-speed roads like highways, similar to `MBDirectionsProfileIdentifierAutomobile`.
*/
extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobileAvoidingTraffic;

/**
The returned directions are appropriate for riding a bicycle.
This profile prioritizes short, safe routes by avoiding highways and preferring cycling infrastructure, such as bike lanes on surface streets. A cycling route may, where necessary, use other modes of transportation, such as ferries or trains, or require dismounting the bicycle for a distance.
*/
extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierCycling;

/**
The returned directions are appropriate for walking or hiking.
This profile prioritizes short routes, making use of sidewalks and trails where available. A walking route may use other modes of transportation, such as ferries or trains, where necessary.
*/
extern MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierWalking;
7 changes: 7 additions & 0 deletions MapboxDirections/MBRouteOptions.m
@@ -0,0 +1,7 @@
#import "MBRouteOptions.h"


MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobile = @"mapbox/driving";
MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierAutomobileAvoidingTraffic = @"mapbox/driving-traffic";
MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierCycling = @"mapbox/cycling";
MBDirectionsProfileIdentifier const MBDirectionsProfileIdentifierWalking = @"mapbox/walking";
38 changes: 2 additions & 36 deletions MapboxDirections/MBRouteOptions.swift
@@ -1,37 +1,3 @@
// MARK: Specifying the Routing Profile

/**
The returned directions are appropriate for driving or riding a car, truck, or motorcycle.
This profile prioritizes fast routes by preferring high-speed roads like highways. A driving route may use a ferry where necessary.
*/
public let MBDirectionsProfileIdentifierAutomobile = "mapbox/driving"

/**
The returned directions are appropriate for driving or riding a car, truck, or motorcycle.
This profile avoids traffic congestion based on current traffic data. A driving route may use a ferry where necessary.
- experiment: This profile is experimental. Where traffic data is absent, this profile prefers high-speed roads like highways, similar to `MBDirectionsProfileIdentifierAutomobile`.
*/
public let MBDirectionsProfileIdentifierAutomobileAvoidingTraffic = "mapbox/driving-traffic"

/**
The returned directions are appropriate for riding a bicycle.
This profile prioritizes short, safe routes by avoiding highways and preferring cycling infrastructure, such as bike lanes on surface streets. A cycling route may, where necessary, use other modes of transportation, such as ferries or trains, or require dismounting the bicycle for a distance.
*/
public let MBDirectionsProfileIdentifierCycling = "mapbox/cycling"

/**
The returned directions are appropriate for walking or hiking.
This profile prioritizes short routes, making use of sidewalks and trails where available. A walking route may use other modes of transportation, such as ferries or trains, where necessary.
*/
public let MBDirectionsProfileIdentifierWalking = "mapbox/walking"

// MARK: -

/**
A `RouteShapeFormat` indicates the format of a route’s shape in the raw HTTP response.
*/
Expand Down Expand Up @@ -144,8 +110,8 @@ open class RouteOptions: NSObject {
assert(waypoints.count <= 25, "A route may not have more than 25 waypoints.")

self.waypoints = waypoints
self.profileIdentifier = profileIdentifier ?? MBDirectionsProfileIdentifierAutomobile
self.allowsUTurnAtWaypoint = ![MBDirectionsProfileIdentifierAutomobile, MBDirectionsProfileIdentifierAutomobileAvoidingTraffic].contains(self.profileIdentifier)
self.profileIdentifier = profileIdentifier ?? MBDirectionsProfileIdentifier.automobile.rawValue
self.allowsUTurnAtWaypoint = ![MBDirectionsProfileIdentifier.automobile, MBDirectionsProfileIdentifier.automobileAvoidingTraffic].contains(MBDirectionsProfileIdentifier(rawValue: self.profileIdentifier))
}

/**
Expand Down
1 change: 1 addition & 0 deletions MapboxDirections/MapboxDirections.h
Expand Up @@ -8,3 +8,4 @@ FOUNDATION_EXPORT double MapboxDirectionsVersionNumber;
FOUNDATION_EXPORT const unsigned char MapboxDirectionsVersionString[];

#import "MBLaneIndication.h"
#import "MBRouteOptions.h"

0 comments on commit 26d2fdc

Please sign in to comment.