diff --git a/CHANGELOG.md b/CHANGELOG.md index f91f2e7cb13..b4726031bf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ * MapboxCoreNavigation now requires [MapboxDirections v2.11.0](https://github.com/mapbox/mapbox-directions-swift/releases/tag/v2.11.0). ([#4523](https://github.com/mapbox/mapbox-navigation-ios/pull/4523)) +### Other changes + +* Added filling jartic traffic codes info reported `Incident`s while navigating. ([#4524](https://github.com/mapbox/mapbox-navigation-ios/pull/4524)) + ## v2.15.0 ### Packaging diff --git a/Sources/MapboxCoreNavigation/Incident.swift b/Sources/MapboxCoreNavigation/Incident.swift index 45c7e41381f..55bb58bf783 100644 --- a/Sources/MapboxCoreNavigation/Incident.swift +++ b/Sources/MapboxCoreNavigation/Incident.swift @@ -52,7 +52,8 @@ extension Incident { longDescription: incidentInfo.longDescription, numberOfBlockedLanes: incidentInfo.numLanesBlocked?.intValue, congestionLevel: incidentInfo.congestion?.value?.intValue, - affectedRoadNames: incidentInfo.affectedRoadNames + affectedRoadNames: incidentInfo.affectedRoadNames, + trafficCodes: .init(incidentInfo.trafficCodes) ) } } @@ -75,3 +76,14 @@ extension Incident.Impact { } } } + +extension Incident.TrafficCodes { + init?(_ data: [String: NSNumber]) { + let codableData = Dictionary(uniqueKeysWithValues: data.map { ($0.key, $0.value.uint32Value) }) + guard let json = try? JSONEncoder().encode(codableData), + let decoded = try? JSONDecoder().decode(Incident.TrafficCodes.self, from: json) else { + return nil + } + self = decoded + } +}