You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When decoding an object from JSON without specifying a RouteOptions or MatchOptions object in the user info dictionary, throw an error instead of force-unwrapping an optional and crashing.
Ensure that waypoints in legs in routes/matches have the same names and leg-separation qualities as in the overall response and options object.
Copy file name to clipboardExpand all lines: Sources/MapboxDirections/MapMatching/Match.swift
+13-1Lines changed: 13 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,11 +16,23 @@ open class Match: DirectionsResult {
16
16
case tracepoints
17
17
case matchOptions
18
18
}
19
+
20
+
/**
21
+
Creates a match from a decoder.
22
+
23
+
- precondition: If the decoder is decoding JSON data from an API response, the `Decoder.userInfo` dictionary must contain a `MatchOptions` object in the `CodingUserInfoKey.options` key. If it does not, a `DirectionsCodingError.missingOptions` error is thrown.
24
+
- parameter decoder: The decoder of JSON-formatted API response data or a previously encoded `Match` object.
Copy file name to clipboardExpand all lines: Sources/MapboxDirections/Route.swift
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,19 @@ open class Route: DirectionsResult {
8
8
case routeOptions
9
9
}
10
10
11
+
/**
12
+
Creates a route from a decoder.
13
+
14
+
- precondition: If the decoder is decoding JSON data from an API response, the `Decoder.userInfo` dictionary must contain a `RouteOptions` or `MatchOptions` object in the `CodingUserInfoKey.options` key. If it does not, a `DirectionsCodingError.missingOptions` error is thrown.
15
+
- parameter decoder: The decoder of JSON-formatted API response data or a previously encoded `Route` object.
Copy file name to clipboardExpand all lines: Sources/MapboxDirections/RouteLeg.swift
+18-3Lines changed: 18 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -28,17 +28,28 @@ open class RouteLeg: Codable {
28
28
29
29
// MARK: Creating a Leg
30
30
31
+
/**
32
+
Creates a route leg from a decoder.
33
+
34
+
- precondition: If the decoder is decoding JSON data from an API response, the `Decoder.userInfo` dictionary must contain a `RouteOptions` or `MatchOptions` object in the `CodingUserInfoKey.options` key. If it does not, a `DirectionsCodingError.missingOptions` error is thrown.
35
+
- parameter decoder: The decoder of JSON-formatted API response data or a previously encoded `RouteLeg` object.
0 commit comments