commit
8ee32b5750
4 changed files with 50 additions and 14 deletions
|
@ -169,8 +169,10 @@ public class TestVoiceActivity extends OsmandActionBarActivity {
|
||||||
addButton(ll, "\u25BA (3.4) After 3100m turn right onto 'SR 80' toward 'Rome'", builder(p).prepareTurn(AbstractPrologCommandPlayer.A_RIGHT, 3100, street(p, "SR 80", "", "Rome")));
|
addButton(ll, "\u25BA (3.4) After 3100m turn right onto 'SR 80' toward 'Rome'", builder(p).prepareTurn(AbstractPrologCommandPlayer.A_RIGHT, 3100, street(p, "SR 80", "", "Rome")));
|
||||||
addButton(ll, "\u25BA (3.5) In 370m turn slightly right onto 'Route 23' 'Main Street', then bear left", builder(p).turn(AbstractPrologCommandPlayer.A_RIGHT_SL, 370, street(p, "Route 23", "Main Street", "")).then().bearLeft(street(p, "")));
|
addButton(ll, "\u25BA (3.5) In 370m turn slightly right onto 'Route 23' 'Main Street', then bear left", builder(p).turn(AbstractPrologCommandPlayer.A_RIGHT_SL, 370, street(p, "Route 23", "Main Street", "")).then().bearLeft(street(p, "")));
|
||||||
addButton(ll, "\u25BA (3.6) Turn sharply right onto 'Dr.-Quinn-Stra"+"\u00df"+"e'", builder(p).turn(AbstractPrologCommandPlayer.A_RIGHT_SH, street(p, "", "Dr.-Quinn-Straße", "")));
|
addButton(ll, "\u25BA (3.6) Turn sharply right onto 'Dr.-Quinn-Stra"+"\u00df"+"e'", builder(p).turn(AbstractPrologCommandPlayer.A_RIGHT_SH, street(p, "", "Dr.-Quinn-Straße", "")));
|
||||||
addButton(ll, "\u25BA (3.7) Turn slightly right to exit 6 onto 'Amsterdam-Osdorp'", builder(p).takeExit(AbstractPrologCommandPlayer.A_RIGHT_SL, 6, street(p, "", "Amsterdam-Osdorp", "")));
|
addButton(ll, "\u25BA (3.7) Turn slightly right to exit 6 onto 'Amsterdam-Osdorp'", builder(p).takeExit(AbstractPrologCommandPlayer.A_RIGHT_SL, "6", 6, street(p, "", "Amsterdam-Osdorp", "")));
|
||||||
addButton(ll, "\u25BA (3.8) In 350m turn slightly right to exit 6 onto 'Amsterdam-Osdorp'", builder(p).takeExit(AbstractPrologCommandPlayer.A_RIGHT_SL, 350, 6, street(p, "", "Amsterdam-Osdorp", "")));
|
addButton(ll, "\u25BA (3.8) In 350m turn slightly right to exit 6 onto 'Amsterdam-Osdorp'", builder(p).takeExit(AbstractPrologCommandPlayer.A_RIGHT_SL, 350, "6", 6, street(p, "", "Amsterdam-Osdorp", "")));
|
||||||
|
addButton(ll, "\u25BA (3.9) Turn slightly right to exit 260B ", builder(p).takeExit(AbstractPrologCommandPlayer.A_RIGHT_SL, "260 B", 260, street(p, "", "", "")));
|
||||||
|
addButton(ll, "\u25BA (3.10) Turn slightly left to exit 15B ", builder(p).takeExit(AbstractPrologCommandPlayer.A_LEFT_SL, "15 B", 15, street(p, "", "", "")));
|
||||||
|
|
||||||
addButton(ll, "Keep left/right: prepareTurn, makeTurnIn, turn:", builder(p));
|
addButton(ll, "Keep left/right: prepareTurn, makeTurnIn, turn:", builder(p));
|
||||||
addButton(ll, "\u25BA (4.1) After 1810m keep left ' '", builder(p).prepareTurn(AbstractPrologCommandPlayer.A_LEFT_KEEP, 1810, street(p, "")));
|
addButton(ll, "\u25BA (4.1) After 1810m keep left ' '", builder(p).prepareTurn(AbstractPrologCommandPlayer.A_LEFT_KEEP, 1810, street(p, "")));
|
||||||
|
|
|
@ -21,6 +21,7 @@ import net.osmand.plus.voice.CommandPlayer;
|
||||||
import net.osmand.router.ExitInfo;
|
import net.osmand.router.ExitInfo;
|
||||||
import net.osmand.router.RouteSegmentResult;
|
import net.osmand.router.RouteSegmentResult;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -702,6 +703,37 @@ public class VoiceRouter {
|
||||||
play(p);
|
play(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getSpeakableExitRef(String exit) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (exit != null) {
|
||||||
|
exit = exit.replace('-', ' ');
|
||||||
|
exit = exit.replace(':', ' ');
|
||||||
|
// Add spaces between digits and letters for better pronunciation
|
||||||
|
int length = exit.length();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
if (i + 1 < length && Character.isDigit(exit.charAt(i)) && Character.isLetter(exit.charAt(i + 1))) {
|
||||||
|
sb.append(exit.charAt(i));
|
||||||
|
sb.append(' ');
|
||||||
|
} else {
|
||||||
|
sb.append(exit.charAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getIntRef(String stringRef) {
|
||||||
|
int intRef = Algorithms.findFirstNumberEndIndex(stringRef);
|
||||||
|
if (intRef > 0) {
|
||||||
|
try {
|
||||||
|
intRef = (int) Float.parseFloat(stringRef.substring(0, intRef));
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
intRef = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return intRef;
|
||||||
|
}
|
||||||
|
|
||||||
private void playMakeTurnIn(RouteSegmentResult currentSegment, RouteDirectionInfo next, int dist, RouteDirectionInfo pronounceNextNext) {
|
private void playMakeTurnIn(RouteSegmentResult currentSegment, RouteDirectionInfo next, int dist, RouteDirectionInfo pronounceNextNext) {
|
||||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
|
@ -709,8 +741,9 @@ public class VoiceRouter {
|
||||||
boolean isPlay = true;
|
boolean isPlay = true;
|
||||||
ExitInfo exitInfo = next.getExitInfo();
|
ExitInfo exitInfo = next.getExitInfo();
|
||||||
if (tParam != null) {
|
if (tParam != null) {
|
||||||
if (exitInfo != null) {
|
if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef())) {
|
||||||
p.takeExit(tParam, dist, Integer.parseInt(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true));
|
String stringRef = getSpeakableExitRef(exitInfo.getRef());
|
||||||
|
p.takeExit(tParam, dist, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, true));
|
||||||
} else {
|
} else {
|
||||||
p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true));
|
p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true));
|
||||||
}
|
}
|
||||||
|
@ -782,8 +815,9 @@ public class VoiceRouter {
|
||||||
ExitInfo exitInfo = next.getExitInfo();
|
ExitInfo exitInfo = next.getExitInfo();
|
||||||
boolean isplay = true;
|
boolean isplay = true;
|
||||||
if (tParam != null) {
|
if (tParam != null) {
|
||||||
if (exitInfo != null) {
|
if (exitInfo != null && !Algorithms.isEmpty(exitInfo.getRef())) {
|
||||||
p.takeExit(tParam, Integer.parseInt(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest));
|
String stringRef = getSpeakableExitRef(exitInfo.getRef());
|
||||||
|
p.takeExit(tParam, stringRef, getIntRef(exitInfo.getRef()), getSpeakableExitName(next, exitInfo, !suppressDest));
|
||||||
} else {
|
} else {
|
||||||
p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest));
|
p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest));
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,12 +179,12 @@ public class CommandBuilder {
|
||||||
return alt(prepareStruct(C_TURN, param, dist, streetName), prepareStruct(C_TURN, param, dist));
|
return alt(prepareStruct(C_TURN, param, dist, streetName), prepareStruct(C_TURN, param, dist));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder takeExit(String turnType, int exit, StreetName streetName) {
|
public CommandBuilder takeExit(String turnType, String exitString, int exitInt, StreetName streetName) {
|
||||||
return alt(prepareStruct(C_TAKE_EXIT, turnType, exit, streetName), prepareStruct(C_TAKE_EXIT, turnType, exit));
|
return alt(prepareStruct(C_TAKE_EXIT, turnType, exitString, exitInt, streetName), prepareStruct(C_TAKE_EXIT, turnType, exitString, exitInt));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandBuilder takeExit(String turnType, double dist, int exit, StreetName streetName) {
|
public CommandBuilder takeExit(String turnType, double dist, String exitString,int exitInt, StreetName streetName) {
|
||||||
return alt(prepareStruct(C_TAKE_EXIT, turnType, dist, exit, streetName), prepareStruct(C_TAKE_EXIT, turnType, dist, exit));
|
return alt(prepareStruct(C_TAKE_EXIT, turnType, dist, exitString, exitInt, streetName), prepareStruct(C_TAKE_EXIT, turnType, dist, exitString, exitInt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -119,13 +119,13 @@ public class JSCommandBuilder extends CommandBuilder {
|
||||||
return addCommand(C_TURN, param, dist, convertStreetName(streetName));
|
return addCommand(C_TURN, param, dist, convertStreetName(streetName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSCommandBuilder takeExit(String turnType, int exit, StreetName streetName) {
|
public JSCommandBuilder takeExit(String turnType, String exitString, int exitInt, StreetName streetName) {
|
||||||
return takeExit(turnType, -1, exit, streetName);
|
return takeExit(turnType, -1, exitString, exitInt, streetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSCommandBuilder takeExit(String turnType, double dist, int exit, StreetName streetName) {
|
public JSCommandBuilder takeExit(String turnType, double dist, String exitString, int exitInt, StreetName streetName) {
|
||||||
return isJSCommandExists(C_TAKE_EXIT) ?
|
return isJSCommandExists(C_TAKE_EXIT) ?
|
||||||
addCommand(C_TAKE_EXIT, turnType, dist, exit, convertStreetName(streetName)) :
|
addCommand(C_TAKE_EXIT, turnType, dist, exitString, exitInt, convertStreetName(streetName)) :
|
||||||
addCommand(C_TURN, turnType, dist, convertStreetName(streetName));
|
addCommand(C_TURN, turnType, dist, convertStreetName(streetName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue