diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 4f03920350..35839f0d7f 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -709,12 +709,11 @@ public class VoiceRouter { boolean isPlay = true; ExitInfo exitInfo = next.getExitInfo(); if (tParam != null) { - p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true)); -// if (exitInfo != null) { -// p.takeExit(tParam, dist, getSpeakableExitName(next, exitInfo, true)); -// } else { -// p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true)); -// } + if (exitInfo != null) { + p.takeExit(tParam, dist, Integer.parseInt(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true)); + } else { + p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true)); + } suppressDest = true; } else if (next.getTurnType().isRoundAbout()) { p.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, true)); @@ -783,12 +782,11 @@ public class VoiceRouter { ExitInfo exitInfo = next.getExitInfo(); boolean isplay = true; if (tParam != null) { - p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest)); -// if (exitInfo != null) { -// p.takeExit(tParam, getSpeakableExitName(next, exitInfo, !suppressDest)); -// } else { -// p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest)); -// } + if (exitInfo != null) { + p.takeExit(tParam, Integer.parseInt(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest)); + } else { + p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest)); + } } else if (next.getTurnType().isRoundAbout()) { p.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, !suppressDest)); } else if (next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU) { diff --git a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java index 65a28b70e6..481b263d9a 100644 --- a/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java +++ b/OsmAnd/src/net/osmand/plus/voice/CommandBuilder.java @@ -179,12 +179,12 @@ public class CommandBuilder { return alt(prepareStruct(C_TURN, param, dist, streetName), prepareStruct(C_TURN, param, dist)); } - public CommandBuilder takeExit(String turnType, StreetName streetName) { - return alt(prepareStruct(C_TAKE_EXIT, turnType, streetName), prepareStruct(C_TAKE_EXIT, turnType)); + public CommandBuilder takeExit(String turnType, int exit, StreetName streetName) { + return alt(prepareStruct(C_TAKE_EXIT, turnType, exit, streetName), prepareStruct(C_TAKE_EXIT, turnType, exit)); } - public CommandBuilder takeExit(String turnType, double dist, StreetName streetName) { - return alt(prepareStruct(C_TAKE_EXIT, turnType, dist, streetName), prepareStruct(C_TAKE_EXIT, turnType, dist)); + public CommandBuilder takeExit(String turnType, double dist, int exit, StreetName streetName) { + return alt(prepareStruct(C_TAKE_EXIT, turnType, dist, exit, streetName), prepareStruct(C_TAKE_EXIT, turnType, dist, exit)); } /** diff --git a/OsmAnd/src/net/osmand/plus/voice/JSCommandBuilder.java b/OsmAnd/src/net/osmand/plus/voice/JSCommandBuilder.java index dfdfcea29a..057ba29a32 100644 --- a/OsmAnd/src/net/osmand/plus/voice/JSCommandBuilder.java +++ b/OsmAnd/src/net/osmand/plus/voice/JSCommandBuilder.java @@ -65,6 +65,10 @@ public class JSCommandBuilder extends CommandBuilder { return this; } + private boolean isJSCommandExists(String name) { + return jsScope.get(name) instanceof Function; + } + public JSCommandBuilder goAhead(){ return goAhead(-1, new StreetName()); } @@ -115,12 +119,14 @@ public class JSCommandBuilder extends CommandBuilder { return addCommand(C_TURN, param, dist, convertStreetName(streetName)); } - public JSCommandBuilder takeExit(String turnType, StreetName streetName) { - return takeExit(turnType, -1, streetName); + public JSCommandBuilder takeExit(String turnType, int exit, StreetName streetName) { + return takeExit(turnType, -1, exit, streetName); } - public JSCommandBuilder takeExit(String turnType, double dist, StreetName streetName) { - return addCommand(C_TAKE_EXIT, turnType, dist, convertStreetName(streetName)); + public JSCommandBuilder takeExit(String turnType, double dist, int exit, StreetName streetName) { + return isJSCommandExists(C_TAKE_EXIT) ? + addCommand(C_TAKE_EXIT, turnType, dist, exit, convertStreetName(streetName)) : + addCommand(C_TURN, turnType, dist, convertStreetName(streetName)); } /**