Skip to content

Commit

Permalink
Attributes (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobby Sudekum authored Apr 10, 2017
1 parent 603d243 commit a962094
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 2 deletions.
44 changes: 44 additions & 0 deletions MapboxDirections.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@
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 */; };
C51538CC1E807FF00093FF3E /* MBAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51538CB1E807FF00093FF3E /* MBAttribute.swift */; };
C5247D711E818A24004B6154 /* AnnotationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5247D701E818A24004B6154 /* AnnotationTests.swift */; };
C53A02261E92C26E009837BD /* MBAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51538CB1E807FF00093FF3E /* MBAttribute.swift */; };
C53A02271E92C26F009837BD /* MBAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51538CB1E807FF00093FF3E /* MBAttribute.swift */; };
C53A02281E92C271009837BD /* MBAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = C51538CB1E807FF00093FF3E /* MBAttribute.swift */; };
C53A02291E92C27A009837BD /* AnnotationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5247D701E818A24004B6154 /* AnnotationTests.swift */; };
C53A022A1E92C27B009837BD /* AnnotationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5247D701E818A24004B6154 /* AnnotationTests.swift */; };
C53A022B1E92C281009837BD /* annotation.json in Resources */ = {isa = PBXBuildFile; fileRef = C5A3D3971E8188FE00D494A0 /* annotation.json */; };
C53A022C1E92C281009837BD /* annotation.json in Resources */ = {isa = PBXBuildFile; fileRef = C5A3D3971E8188FE00D494A0 /* annotation.json */; };
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 */; };
C558C58C1E94196100617B37 /* MBAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = C558C58B1E94181A00617B37 /* MBAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
C558C58D1E94196200617B37 /* MBAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = C558C58B1E94181A00617B37 /* MBAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
C558C58E1E94196200617B37 /* MBAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = C558C58B1E94181A00617B37 /* MBAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
C558C58F1E94196300617B37 /* MBAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = C558C58B1E94181A00617B37 /* MBAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
C57B2E961DB8171300E9123A /* MBLaneIndication.h in Headers */ = {isa = PBXBuildFile; fileRef = C57B2E951DB8171300E9123A /* MBLaneIndication.h */; settings = {ATTRIBUTES = (Public, ); }; };
C57B2E971DB8171300E9123A /* MBLaneIndication.h in Headers */ = {isa = PBXBuildFile; fileRef = C57B2E951DB8171300E9123A /* MBLaneIndication.h */; settings = {ATTRIBUTES = (Public, ); }; };
C57B2E981DB8171300E9123A /* MBLaneIndication.h in Headers */ = {isa = PBXBuildFile; fileRef = C57B2E951DB8171300E9123A /* MBLaneIndication.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -27,6 +40,7 @@
C57D55041DB566A800B94B74 /* MBIntersection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55001DB5669600B94B74 /* MBIntersection.swift */; };
C57D55051DB566A900B94B74 /* MBIntersection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55001DB5669600B94B74 /* MBIntersection.swift */; };
C57D55081DB58C0200B94B74 /* MBLane.swift in Sources */ = {isa = PBXBuildFile; fileRef = C57D55071DB58C0200B94B74 /* MBLane.swift */; };
C5A3D3981E8188FE00D494A0 /* annotation.json in Resources */ = {isa = PBXBuildFile; fileRef = C5A3D3971E8188FE00D494A0 /* annotation.json */; };
DA1A10C61D00F969009F82FA /* MapboxDirections.h in Headers */ = {isa = PBXBuildFile; fileRef = DA6C9D8A1CAE442B00094FBC /* MapboxDirections.h */; settings = {ATTRIBUTES = (Public, ); }; };
DA1A10C71D00F969009F82FA /* MBDirections.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6254731AE70CB700017857 /* MBDirections.swift */; };
DA1A10C81D00F969009F82FA /* MBRoute.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC05F171CFC075300FA0071 /* MBRoute.swift */; };
Expand Down Expand Up @@ -142,9 +156,13 @@
/* Begin PBXFileReference section */
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>"; };
C51538CB1E807FF00093FF3E /* MBAttribute.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MBAttribute.swift; sourceTree = "<group>"; };
C5247D701E818A24004B6154 /* AnnotationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnnotationTests.swift; sourceTree = "<group>"; };
C558C58B1E94181A00617B37 /* MBAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MBAttribute.h; sourceTree = "<group>"; };
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>"; };
C5A3D3971E8188FE00D494A0 /* annotation.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = annotation.json; path = v5/annotation.json; 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 @@ -283,6 +301,14 @@
name = "iOS Frameworks";
sourceTree = "<group>";
};
C5247D721E818A8D004B6154 /* annotation */ = {
isa = PBXGroup;
children = (
C5A3D3971E8188FE00D494A0 /* annotation.json */,
);
name = annotation;
sourceTree = "<group>";
};
DA6C9D891CAE442B00094FBC /* MapboxDirections */ = {
isa = PBXGroup;
children = (
Expand All @@ -299,6 +325,8 @@
C57B2E951DB8171300E9123A /* MBLaneIndication.h */,
DAA76D671DD127CB0015EC78 /* MBLaneIndication.swift */,
DAC05F151CFBFAC400FA0071 /* MBWaypoint.swift */,
C51538CB1E807FF00093FF3E /* MBAttribute.swift */,
C558C58B1E94181A00617B37 /* MBAttribute.h */,
DA6C9D8C1CAE442B00094FBC /* Info.plist */,
);
path = MapboxDirections;
Expand All @@ -312,6 +340,7 @@
DA737EE71D0611CB005BDA16 /* V4Tests.swift */,
DA6C9DAB1CAEC72800094FBC /* V5Tests.swift */,
DA6C9DB11CAECA0E00094FBC /* Fixture.swift */,
C5247D701E818A24004B6154 /* AnnotationTests.swift */,
DA6C9D9A1CAE442B00094FBC /* Info.plist */,
DA6C9DAD1CAEC93800094FBC /* Fixtures */,
);
Expand All @@ -321,6 +350,7 @@
DA6C9DAD1CAEC93800094FBC /* Fixtures */ = {
isa = PBXGroup;
children = (
C5247D721E818A8D004B6154 /* annotation */,
DA737EEC1D061514005BDA16 /* V4 */,
DA737EEB1D0614FA005BDA16 /* V5 */,
);
Expand Down Expand Up @@ -453,6 +483,7 @@
files = (
358D48821E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA1A10C61D00F969009F82FA /* MapboxDirections.h in Headers */,
C558C58D1E94196200617B37 /* MBAttribute.h in Headers */,
C57B2E971DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -463,6 +494,7 @@
files = (
358D48831E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA1A10EC1D010247009F82FA /* MapboxDirections.h in Headers */,
C558C58E1E94196200617B37 /* MBAttribute.h in Headers */,
C57B2E981DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -473,6 +505,7 @@
files = (
358D48841E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA1A11031D0103A3009F82FA /* MapboxDirections.h in Headers */,
C558C58F1E94196300617B37 /* MBAttribute.h in Headers */,
C57B2E991DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -483,6 +516,7 @@
files = (
358D48811E2EAB2500F32A65 /* MBRouteOptions.h in Headers */,
DA6C9D8B1CAE442B00094FBC /* MapboxDirections.h in Headers */,
C558C58C1E94196100617B37 /* MBAttribute.h in Headers */,
C57B2E961DB8171300E9123A /* MBLaneIndication.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -744,6 +778,7 @@
DA737EE51D05F91E005BDA16 /* v5_driving_dc_geojson.json in Resources */,
DA1A10CF1D00F975009F82FA /* v5_driving_dc_polyline.json in Resources */,
DA737EEF1D06175B005BDA16 /* v4_driving_dc_geojson.json in Resources */,
C53A022B1E92C281009837BD /* annotation.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -762,6 +797,7 @@
DA737EE61D05F91E005BDA16 /* v5_driving_dc_geojson.json in Resources */,
DA1A10F31D010251009F82FA /* v5_driving_dc_polyline.json in Resources */,
DA737EF01D06175B005BDA16 /* v4_driving_dc_geojson.json in Resources */,
C53A022C1E92C281009837BD /* annotation.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -787,6 +823,7 @@
DA737EE41D05F91E005BDA16 /* v5_driving_dc_geojson.json in Resources */,
DAC05F1C1CFC1E5300FA0071 /* v5_driving_dc_polyline.json in Resources */,
DA737EEE1D06175B005BDA16 /* v4_driving_dc_geojson.json in Resources */,
C5A3D3981E8188FE00D494A0 /* annotation.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -848,6 +885,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C53A02261E92C26E009837BD /* MBAttribute.swift in Sources */,
DA1A10C91D00F969009F82FA /* MBRouteLeg.swift in Sources */,
358D48871E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DA1A10CC1D00F969009F82FA /* MBWaypoint.swift in Sources */,
Expand All @@ -865,6 +903,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C53A02291E92C27A009837BD /* AnnotationTests.swift in Sources */,
DA1A10CD1D00F972009F82FA /* V5Tests.swift in Sources */,
DA737EE91D0611CB005BDA16 /* V4Tests.swift in Sources */,
DA1A10CE1D00F972009F82FA /* Fixture.swift in Sources */,
Expand All @@ -877,6 +916,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C53A02271E92C26F009837BD /* MBAttribute.swift in Sources */,
DA1A10EF1D010247009F82FA /* MBRouteLeg.swift in Sources */,
358D48881E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DA1A10F21D010247009F82FA /* MBWaypoint.swift in Sources */,
Expand All @@ -894,6 +934,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C53A022A1E92C27B009837BD /* AnnotationTests.swift in Sources */,
DA1A10F41D010251009F82FA /* V5Tests.swift in Sources */,
DA737EEA1D0611CB005BDA16 /* V4Tests.swift in Sources */,
DA1A10F51D010251009F82FA /* Fixture.swift in Sources */,
Expand All @@ -906,6 +947,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C53A02281E92C271009837BD /* MBAttribute.swift in Sources */,
DA1A11061D0103A3009F82FA /* MBRouteLeg.swift in Sources */,
358D48891E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DA1A11091D0103A3009F82FA /* MBWaypoint.swift in Sources */,
Expand All @@ -923,6 +965,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C51538CC1E807FF00093FF3E /* MBAttribute.swift in Sources */,
DA2E03EB1CB0E13D00D1269A /* MBRouteOptions.swift in Sources */,
358D48861E2EAB4500F32A65 /* MBRouteOptions.m in Sources */,
DAC05F161CFBFAC400FA0071 /* MBWaypoint.swift in Sources */,
Expand All @@ -940,6 +983,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C5247D711E818A24004B6154 /* AnnotationTests.swift in Sources */,
DA6C9DAC1CAEC72800094FBC /* V5Tests.swift in Sources */,
DA737EE81D0611CB005BDA16 /* V4Tests.swift in Sources */,
DA6C9DB21CAECA0E00094FBC /* Fixture.swift in Sources */,
Expand Down
17 changes: 17 additions & 0 deletions MapboxDirections/MBAttribute.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
Attributes are metadata information for a given route. The number of attributes returned will be a direct 1-1 relationship with the route's full geometry. The `.distance`, `.expectedTravelTime`, and `.speed` attributes have one fewer value than the `.openStreetMapNodeIdentifier` attribute.
*/
typedef NS_OPTIONS(NSUInteger, MBAttributeOptions) {

/// Segment distance. Distances are measured in meters.
MBAttributeDistance = (1 << 1),

// Segment expected travel time in seconds.
MBAttributeExpectedTravelTime = (1 << 2),

// Segment current speed. Speeds are measured in meters per second.
MBAttributeSpeed = (1 << 3),

// [OpenStreetMap node identifier](https://wiki.openstreetmap.org/wiki/Node).
MBAttributeOpenStreetMapNodeIdentifier = (1 << 4)
};
42 changes: 42 additions & 0 deletions MapboxDirections/MBAttribute.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Foundation

public typealias AttributeOptions = MBAttributeOptions

extension AttributeOptions: CustomStringConvertible {
/**
Creates an AttributeOptions from the given description strings.
*/
public init?(description: String) {
var scope: AttributeOptions = []
switch description {
case "distance":
scope.update(with: .distance)
case "expectedTravelTime":
scope.update(with: .expectedTravelTime)
case "openStreetMapNodeIdentifier":
scope.update(with: .openStreetMapNodeIdentifier)
case "speed":
scope.update(with: .speed)
default:
return nil
}
self.init(rawValue: scope.rawValue)
}

public var description: String {
var descriptions: [String] = []
if contains(.distance) {
descriptions.append("distance")
}
if contains(.expectedTravelTime) {
descriptions.append("duration")
}
if contains(.openStreetMapNodeIdentifier) {
descriptions.append("nodes")
}
if contains(.speed) {
descriptions.append("speed")
}
return descriptions.joined(separator: ",")
}
}
Loading

0 comments on commit a962094

Please sign in to comment.