Skip to content

Commit

Permalink
Decode polyline6
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Jun 21, 2018
1 parent 3faf9f0 commit d3b7467
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions MapboxDirections.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
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 */; };
35CEAF7020DC466E000308F8 /* v5_driving_dc_polyline6.json in Resources */ = {isa = PBXBuildFile; fileRef = 35CEAF6F20DC466E000308F8 /* v5_driving_dc_polyline6.json */; };
35CEAF7120DC466E000308F8 /* v5_driving_dc_polyline6.json in Resources */ = {isa = PBXBuildFile; fileRef = 35CEAF6F20DC466E000308F8 /* v5_driving_dc_polyline6.json */; };
35CEAF7220DC466E000308F8 /* v5_driving_dc_polyline6.json in Resources */ = {isa = PBXBuildFile; fileRef = 35CEAF6F20DC466E000308F8 /* v5_driving_dc_polyline6.json */; };
35EFD00B207DFACA00BF3873 /* MBVisualInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35EFD00A207DFACA00BF3873 /* MBVisualInstruction.swift */; };
35EFD00C207DFACA00BF3873 /* MBVisualInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35EFD00A207DFACA00BF3873 /* MBVisualInstruction.swift */; };
35EFD00D207DFACA00BF3873 /* MBVisualInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35EFD00A207DFACA00BF3873 /* MBVisualInstruction.swift */; };
Expand Down Expand Up @@ -260,6 +263,7 @@
/* 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>"; };
35CEAF6F20DC466E000308F8 /* v5_driving_dc_polyline6.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = v5_driving_dc_polyline6.json; sourceTree = "<group>"; };
35EFD00A207DFACA00BF3873 /* MBVisualInstruction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MBVisualInstruction.swift; sourceTree = "<group>"; };
8D381B601FD9F5B1008D5A58 /* noDestinationName.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = noDestinationName.json; sourceTree = "<group>"; };
8D381B621FDB01D1008D5A58 /* apiDestinationName.json */ = {isa = PBXFileReference; explicitFileType = text.json; path = apiDestinationName.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -580,6 +584,7 @@
children = (
DA737EE31D05F91E005BDA16 /* v5_driving_dc_geojson.json */,
DAC05F1B1CFC1E5300FA0071 /* v5_driving_dc_polyline.json */,
35CEAF6F20DC466E000308F8 /* v5_driving_dc_polyline6.json */,
);
name = V5;
path = v5;
Expand Down Expand Up @@ -1007,6 +1012,7 @@
8D381B661FDB089E008D5A58 /* apiDestinationName.json in Resources */,
8D381B641FDB0898008D5A58 /* noDestinationName.json in Resources */,
C5DAACB5201AA9A7001F9261 /* match.json in Resources */,
35CEAF7120DC466E000308F8 /* v5_driving_dc_polyline6.json in Resources */,
DA737EEF1D06175B005BDA16 /* v4_driving_dc_geojson.json in Resources */,
C53A022B1E92C281009837BD /* annotation.json in Resources */,
);
Expand All @@ -1031,6 +1037,7 @@
8D381B671FDB089F008D5A58 /* apiDestinationName.json in Resources */,
8D381B651FDB0899008D5A58 /* noDestinationName.json in Resources */,
C5DAACB6201AA9A7001F9261 /* match.json in Resources */,
35CEAF7220DC466E000308F8 /* v5_driving_dc_polyline6.json in Resources */,
DA737EF01D06175B005BDA16 /* v4_driving_dc_geojson.json in Resources */,
C53A022C1E92C281009837BD /* annotation.json in Resources */,
);
Expand Down Expand Up @@ -1062,6 +1069,7 @@
8D381B611FD9F5B1008D5A58 /* noDestinationName.json in Resources */,
DA737EEE1D06175B005BDA16 /* v4_driving_dc_geojson.json in Resources */,
C5DAACB4201AA9A7001F9261 /* match.json in Resources */,
35CEAF7020DC466E000308F8 /* v5_driving_dc_polyline6.json in Resources */,
C5A3D3981E8188FE00D494A0 /* annotation.json in Resources */,
8D381B631FDB01D1008D5A58 /* apiDestinationName.json in Resources */,
);
Expand Down
3 changes: 2 additions & 1 deletion MapboxDirections/MBRoute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ open class Route: DirectionsResult {
case let geometry as JSONDictionary:
coordinates = CLLocationCoordinate2D.coordinates(geoJSON: geometry)
case let geometry as String:
coordinates = decodePolyline(geometry, precision: 1e5)!
let precision = routeOptions.shapeFormat == .polyline ? 1e5 : 1e6
coordinates = decodePolyline(geometry, precision: precision)!
default:
coordinates = nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"routes":[{"geometry":"mhafiAbmu|qCjb@E?|nFjuR~@?fwDp~Gg@Ke{A","legs":[{"summary":"16th Street Northwest, 17th Street Northwest","weight":1016.1,"duration":639.8,"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[180],"location":[-77.032674,38.913175]},{"out":1,"in":0,"entry":[false,true,true],"bearings":[0,180,270],"location":[-77.032674,38.913152]}],"driving_side":"right","geometry":"mhafiAbmu|qCl@?j_@Ep@?","mode":"driving","maneuver":{"bearing_after":180,"bearing_before":0,"location":[-77.032674,38.913175],"modifier":"left","type":"depart","instruction":"Head south"},"weight":42.7,"duration":29.8,"name":"","distance":63},{"intersections":[{"out":2,"in":0,"entry":[false,false,true],"bearings":[0,90,270],"location":[-77.032671,38.912609]},{"out":2,"in":1,"entry":[true,false,true],"bearings":[0,90,270],"location":[-77.033245,38.912611]},{"out":3,"in":1,"entry":[true,false,false,true],"bearings":[0,90,180,270],"location":[-77.03455,38.912609]}],"driving_side":"right","geometry":"ae`fiA|lu|qCCzb@Hvf@Ej`@?lG?zD?jBFpk@GpWArd@@nE","mode":"driving","maneuver":{"bearing_after":270,"bearing_before":180,"location":[-77.032671,38.912609],"modifier":"right","type":"end of road","instruction":"Turn right onto R Street Northwest"},"weight":157.2,"duration":100.9,"name":"R Street Northwest","distance":332.3},{"intersections":[{"out":2,"in":1,"entry":[true,false,true,true],"bearings":[0,90,180,270],"location":[-77.03651,38.912609]},{"out":2,"in":0,"entry":[false,false,true,false],"bearings":[0,90,180,270],"location":[-77.036518,38.911869]},{"out":2,"in":0,"entry":[false,true,true,false],"bearings":[0,90,180,270],"location":[-77.036514,38.911127]},{"out":2,"in":0,"entry":[false,false,true,true],"bearings":[0,90,180,270],"location":[-77.036516,38.91039]},{"out":2,"in":0,"entry":[false,true,true,true],"bearings":[0,90,180,270],"location":[-77.036518,38.909656]},{"out":3,"in":0,"entry":[false,false,false,true,true,true],"bearings":[0,90,150,180,210,270],"location":[-77.03652,38.908696]},{"classes":["tunnel"],"out":1,"in":0,"entry":[false,true],"bearings":[0,180],"location":[-77.03653,38.907558]},{"out":1,"in":0,"entry":[false,true],"bearings":[0,180],"location":[-77.036539,38.906941]},{"out":2,"in":0,"entry":[false,false,true,false],"bearings":[0,15,180,345],"location":[-77.036535,38.905931]},{"out":2,"in":0,"entry":[false,false,true,true],"bearings":[0,90,180,270],"location":[-77.036534,38.905654]},{"out":2,"in":0,"entry":[false,true,true,false],"bearings":[0,90,180,270],"location":[-77.036539,38.903739]},{"out":2,"in":0,"entry":[false,false,true,true],"bearings":[0,90,180,270],"location":[-77.036544,38.902645]}],"driving_side":"right","geometry":"ae`fiAz|||qCxBAv_@L|D@vB@vSCxSCxC?nBAlM@vF@vOHrBGhB@nP?hS?vC@nC?nv@BbfARpe@Pb~@GhPAt_@DxZDtw@AnA?zQ@v_@DvK@~B?rFC","mode":"driving","maneuver":{"bearing_after":180,"bearing_before":268,"location":[-77.03651,38.912609],"modifier":"left","type":"turn","instruction":"Turn left onto 16th Street Northwest"},"weight":288,"duration":202.1,"name":"16th Street Northwest","distance":1121.9},{"intersections":[{"out":3,"in":0,"entry":[false,true,true,true],"bearings":[0,90,180,270],"location":[-77.036542,38.902523]},{"out":2,"in":0,"entry":[false,false,true,true],"bearings":[90,240,270,300],"location":[-77.037008,38.902523]},{"out":3,"in":1,"entry":[false,false,true,true],"bearings":[0,90,180,270],"location":[-77.038519,38.902523]}],"driving_side":"right","geometry":"unleiAz~||qC?vG?jS?l}A?zK?hh@","mode":"driving","maneuver":{"bearing_after":270,"bearing_before":178,"location":[-77.036542,38.902523],"modifier":"right","type":"turn","instruction":"Turn right onto K Street Northwest (US 29)"},"ref":"US 29","weight":93.8,"duration":69.8,"name":"K Street Northwest (US 29)","distance":246.2},{"intersections":[{"out":3,"in":1,"entry":[false,false,false,true],"bearings":[0,90,195,270],"location":[-77.039386,38.902523]},{"out":2,"in":1,"entry":[false,false,true,true],"bearings":[0,90,180,270],"location":[-77.03949,38.902523]},{"out":1,"in":0,"entry":[false,true,false],"bearings":[0,180,270],"location":[-77.039474,38.902402]},{"out":2,"in":0,"entry":[false,false,true,true],"bearings":[0,90,180,270],"location":[-77.039446,38.901333]},{"out":2,"in":0,"entry":[false,true,true,false],"bearings":[0,90,180,270],"location":[-77.039456,38.900204]},{"out":1,"in":0,"entry":[false,true,true],"bearings":[0,180,285],"location":[-77.039468,38.898837]},{"out":1,"in":0,"entry":[false,true,true],"bearings":[0,180,270],"location":[-77.03947,38.89831]}],"driving_side":"right","geometry":"unleiArpb}qC?nEpF_@nIgApp@LvE@tVDjTDrPDzF@zD@pPB|QDd`@FzHB~B@zE?`U@fW?","mode":"driving","maneuver":{"bearing_after":270,"bearing_before":268,"location":[-77.039386,38.902523],"modifier":"left","type":"turn","instruction":"Turn left onto 17th Street Northwest"},"weight":319.5,"duration":179.60000000000002,"name":"17th Street Northwest","distance":521.1},{"intersections":[{"out":1,"in":0,"entry":[false,true,true],"bearings":[0,90,180],"location":[-77.03947,38.897922]}],"driving_side":"right","geometry":"coceiAzub}qCBqI@kECqRIoRCec@","mode":"driving","maneuver":{"bearing_after":90,"bearing_before":180,"location":[-77.03947,38.897922],"modifier":"left","type":"turn","instruction":"Turn left"},"weight":114.9,"duration":57.6,"name":"","distance":127.7},{"intersections":[{"in":0,"entry":[true],"bearings":[270],"location":[-77.037995,38.897928]}],"driving_side":"right","geometry":"ooceiAty_}qC","mode":"driving","maneuver":{"bearing_after":0,"bearing_before":90,"location":[-77.037995,38.897928],"modifier":"straight","type":"arrive","instruction":"You have arrived at White House, straight ahead"},"weight":0,"duration":0,"name":"","distance":0}],"distance":2412}],"weight_name":"routability","weight":1016.1,"duration":639.8,"distance":2412}],"waypoints":[{"name":"","location":[-77.032674,38.913175]},{"name":"","location":[-77.037995,38.897928]}],"code":"Ok","uuid":"cjip0kilx002n4dpbp8273jm1"}
5 changes: 5 additions & 0 deletions MapboxDirectionsTests/V5Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,9 @@ class V5Tests: XCTestCase {
XCTAssertEqual(String(describing: RouteShapeFormat.polyline), "polyline")
test(shapeFormat: .polyline)
}

func testPolyline6() {
XCTAssertEqual(String(describing: RouteShapeFormat.polyline6), "polyline6")
test(shapeFormat: .polyline6)
}
}

0 comments on commit d3b7467

Please sign in to comment.