@@ -212,7 +212,11 @@ public class OSRMInstructionFormatter: Formatter {
212212 // Decide which instruction string to use
213213 // Destination takes precedence over name
214214 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 " ] {
216220 instruction = obj
217221 } else if !wayName. isEmpty, let obj = instructionObject [ " name " ] {
218222 instruction = obj
@@ -225,10 +229,11 @@ public class OSRMInstructionFormatter: Formatter {
225229 if let legIndex = legIndex, let numberOfLegs = numberOfLegs, legIndex != numberOfLegs - 1 {
226230 nthWaypoint = ordinalFormatter. string ( from: ( legIndex + 1 ) as NSNumber )
227231 }
232+ let exitCode = step. exitCodes? . first ?? " "
228233 let destination = step. destinations? . first ?? " "
229- var exit : String = " "
234+ var exitOrdinal : String = " "
230235 if let exitIndex = step. exitIndex, exitIndex <= 10 {
231- exit = ordinalFormatter. string ( from: exitIndex as NSNumber ) !
236+ exitOrdinal = ordinalFormatter. string ( from: exitIndex as NSNumber ) !
232237 }
233238 let modifierConstants = constants [ " modifier " ] as! [ String : String ]
234239 let modifierConstant = modifierConstants [ modifier ?? " straight " ] !
@@ -260,7 +265,8 @@ public class OSRMInstructionFormatter: Formatter {
260265 switch tokenType {
261266 case . wayName: replacement = wayName
262267 case . destination: replacement = destination
263- case . exit: replacement = exit
268+ case . exitCode: replacement = exitCode
269+ case . exitIndex: replacement = exitOrdinal
264270 case . rotaryName: replacement = rotaryName
265271 case . laneInstruction: replacement = laneInstruction ?? " "
266272 case . modifier: replacement = modifierConstant
0 commit comments