@@ -212,7 +212,11 @@ public class OSRMInstructionFormatter: Formatter {
212
212
// Decide which instruction string to use
213
213
// Destination takes precedence over name
214
214
var instruction : String
215
- if let _ = step. destinations, let obj = instructionObject [ " destination " ] {
215
+ if let _ = step. destinations, let _ = step. exitCodes? . first, let obj = instructionObject [ " exit_destination " ] {
216
+ instruction = obj
217
+ } else if let _ = step. destinations, let obj = instructionObject [ " destination " ] {
218
+ instruction = obj
219
+ } else if let _ = step. exitCodes? . first, let obj = instructionObject [ " exit " ] {
216
220
instruction = obj
217
221
} else if !wayName. isEmpty, let obj = instructionObject [ " name " ] {
218
222
instruction = obj
@@ -225,10 +229,11 @@ public class OSRMInstructionFormatter: Formatter {
225
229
if let legIndex = legIndex, let numberOfLegs = numberOfLegs, legIndex != numberOfLegs - 1 {
226
230
nthWaypoint = ordinalFormatter. string ( from: ( legIndex + 1 ) as NSNumber )
227
231
}
232
+ let exitCode = step. exitCodes? . first ?? " "
228
233
let destination = step. destinations? . first ?? " "
229
- var exit : String = " "
234
+ var exitOrdinal : String = " "
230
235
if let exitIndex = step. exitIndex, exitIndex <= 10 {
231
- exit = ordinalFormatter. string ( from: exitIndex as NSNumber ) !
236
+ exitOrdinal = ordinalFormatter. string ( from: exitIndex as NSNumber ) !
232
237
}
233
238
let modifierConstants = constants [ " modifier " ] as! [ String : String ]
234
239
let modifierConstant = modifierConstants [ modifier ?? " straight " ] !
@@ -260,7 +265,8 @@ public class OSRMInstructionFormatter: Formatter {
260
265
switch tokenType {
261
266
case . wayName: replacement = wayName
262
267
case . destination: replacement = destination
263
- case . exit: replacement = exit
268
+ case . exitCode: replacement = exitCode
269
+ case . exitIndex: replacement = exitOrdinal
264
270
case . rotaryName: replacement = rotaryName
265
271
case . laneInstruction: replacement = laneInstruction ?? " "
266
272
case . modifier: replacement = modifierConstant
0 commit comments