diff --git a/CHANGELOG.md b/CHANGELOG.md index aa9ecef83..845576299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changes to Mapbox Directions for Swift +## main + +* This library requires Turf v2.0.0-alpha.2. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) +* This library does not support tvOS, watchOS, or Linux. Support for these platforms will be restored before the final release. ([#517](https://github.com/mapbox/mapbox-directions-swift/pull/517)) +* The `Incident.impact` property is now an `Incident.Impact` value instead of a string. ([#519](https://github.com/mapbox/mapbox-directions-swift/pull/519)) + ## v1.2.0 ### Packaging diff --git a/Sources/MapboxDirections/Incident.swift b/Sources/MapboxDirections/Incident.swift index 7baf5ae27..38a91a88b 100644 --- a/Sources/MapboxDirections/Incident.swift +++ b/Sources/MapboxDirections/Incident.swift @@ -50,7 +50,21 @@ public struct Incident: Codable, Equatable { /// Weather case weather = "weather" } - + + /// Represents the impact of the incident on local traffic. + public enum Impact: String, Codable { + /// Unknown impact + case unknown + /// Critical impact + case critical + /// Major impact + case major + /// Minor impact + case minor + /// Low impact + case low + } + /// Incident identifier public var identifier: String /// The kind of an incident @@ -69,7 +83,7 @@ public struct Incident: Codable, Equatable { /// Date when incident shall end. public var endDate: Date /// Shows severity of an incident. May be not available for all incident types. - public var impact: String? + public var impact: Impact? /// Provides additional classification of an incident. May be not available for all incident types. public var subtype: String? /// Breif description of the subtype. May be not available for all incident types and is not available if `subtype` is `nil` @@ -91,7 +105,7 @@ public struct Incident: Codable, Equatable { creationDate: Date, startDate: Date, endDate: Date, - impact: String?, + impact: Impact?, subtype: String?, subtypeDescription: String?, alertCodes: Set, @@ -142,7 +156,7 @@ public struct Incident: Codable, Equatable { debugDescription: "`Intersection.endTime` is encoded with invalid format.") } - impact = try container.decodeIfPresent(String.self, forKey: .impact) + impact = try container.decodeIfPresent(Impact.self, forKey: .impact) subtype = try container.decodeIfPresent(String.self, forKey: .subtype) subtypeDescription = try container.decodeIfPresent(String.self, forKey: .subtypeDescription) alertCodes = try container.decode(Set.self, forKey: .alertCodes) diff --git a/Tests/MapboxDirectionsTests/RouteStepTests.swift b/Tests/MapboxDirectionsTests/RouteStepTests.swift index 3d4d9a708..78a4a4dfb 100644 --- a/Tests/MapboxDirectionsTests/RouteStepTests.swift +++ b/Tests/MapboxDirectionsTests/RouteStepTests.swift @@ -329,6 +329,7 @@ class RouteStepTests: XCTestCase { XCTAssertNotNil(newRoute) XCTAssert(newRoute!.legs.first!.incidents!.first!.kind == Incident.Kind.miscellaneous) + XCTAssert(newRoute!.legs.first!.incidents!.first!.impact == Incident.Impact.minor) XCTAssert(newRoute!.legs.first!.incidents![0].lanesBlocked!.contains(.right)) XCTAssertNil(newRoute!.legs.first!.incidents![1].lanesBlocked) XCTAssert(newRoute!.legs.first!.incidents![2].lanesBlocked!.isEmpty)