From 1a67e98c803e10061de18023f0a16bce1f37f935 Mon Sep 17 00:00:00 2001 From: Victor Kononov Date: Fri, 24 Feb 2023 12:48:54 +0300 Subject: [PATCH] cherry pick of vk-779-tolls-exclude-fix (#802) --- CHANGELOG.md | 1 + Sources/MapboxDirections/RoadClasses.swift | 4 ++-- Tests/MapboxDirectionsTests/RouteOptionsTests.swift | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e93ecb9..9e874bf59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added `Matrix` API wrapper. The [Mapbox Matrix API](https://docs.mapbox.com/api/navigation/matrix/) computes travel times between many points, and returns a matrix of all travel times between the locations. [#626](https://github.com/mapbox/mapbox-directions-swift/pull/626) * Fixed a crash that could occur if only one `Waypoint` with a nonnull `name` was used in the Directions request. [#797](https://github.com/mapbox/mapbox-directions-swift/pull/797) * Added `Interchange` and `Junction` structs describing IC and JCT. [#799](https://github.com/mapbox/mapbox-directions-swift/pull/799) +* Fixed an issue where using `cashTollOnly` for road class exclusions failed the directions request. ([#801](https://github.com/mapbox/mapbox-directions-swift/pull/801)) ## v2.9.0 diff --git a/Sources/MapboxDirections/RoadClasses.swift b/Sources/MapboxDirections/RoadClasses.swift index 0bd211efd..81e19b8ce 100644 --- a/Sources/MapboxDirections/RoadClasses.swift +++ b/Sources/MapboxDirections/RoadClasses.swift @@ -121,7 +121,7 @@ public struct RoadClasses: OptionSet, CustomStringConvertible { roadClasses.insert(.highOccupancyToll) case "unpaved": roadClasses.insert(.unpaved) - case "cash_only_toll": + case "cash_only_tolls": roadClasses.insert(.cashTollOnly) case "": continue @@ -162,7 +162,7 @@ public struct RoadClasses: OptionSet, CustomStringConvertible { descriptions.append("unpaved") } if contains(.cashTollOnly) { - descriptions.append("cash_only_toll") + descriptions.append("cash_only_tolls") } return descriptions.joined(separator: ",") } diff --git a/Tests/MapboxDirectionsTests/RouteOptionsTests.swift b/Tests/MapboxDirectionsTests/RouteOptionsTests.swift index fb4d8951a..bc3d9ea91 100644 --- a/Tests/MapboxDirectionsTests/RouteOptionsTests.swift +++ b/Tests/MapboxDirectionsTests/RouteOptionsTests.swift @@ -357,7 +357,7 @@ class RouteOptionsTests: XCTestCase { options.roadClassesToAvoid = [.toll, .motorway, .ferry, .unpaved, .cashTollOnly] options.roadClassesToAllow = [.highOccupancyVehicle2, .highOccupancyVehicle3, .highOccupancyToll] - let expectedExcludeQueryItem = URLQueryItem(name: "exclude", value: "toll,motorway,ferry,unpaved,cash_only_toll") + let expectedExcludeQueryItem = URLQueryItem(name: "exclude", value: "toll,motorway,ferry,unpaved,cash_only_tolls") XCTAssertTrue(options.urlQueryItems.contains(expectedExcludeQueryItem)) let expectedIncludeQueryItem = URLQueryItem(name: "include", value: "hov2,hov3,hot")