git-svn-id: https://osmand.googlecode.com/svn/trunk@339 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-07-14 05:39:56 +00:00
parent e0bd461066
commit a12b75915e
5 changed files with 28 additions and 8 deletions

View file

@ -499,17 +499,21 @@ public class RouteProvider {
if(previous.routePointOffset > 0){ if(previous.routePointOffset > 0){
float paz = res.get(previous.routePointOffset - 1).bearingTo(res.get(previous.routePointOffset)); float paz = res.get(previous.routePointOffset - 1).bearingTo(res.get(previous.routePointOffset));
float caz; float caz;
if(previous.turnType.isExit() && dirInfo.routePointOffset < res.size() - 1){ if(previous.turnType.isRoundAbout() && dirInfo.routePointOffset < res.size() - 1){
caz = res.get(dirInfo.routePointOffset).bearingTo(res.get(dirInfo.routePointOffset + 1)); caz = res.get(dirInfo.routePointOffset).bearingTo(res.get(dirInfo.routePointOffset + 1));
} else { } else {
caz = res.get(dirInfo.routePointOffset - 1).bearingTo(res.get(dirInfo.routePointOffset)); caz = res.get(dirInfo.routePointOffset - 1).bearingTo(res.get(dirInfo.routePointOffset));
} }
float angle = caz - paz + 60f; // that magic number helps to fix some errors float angle = caz - paz + 15;
if(angle < 0){ if(angle < 0){
angle += 360; angle += 360;
} else if(angle > 360){ } else if(angle > 360){
angle -= 360; angle -= 360;
} }
// that magic number helps to fix some errors for turn
if(angle < 100){
angle += 45;
}
if(previous.turnType.getTurnAngle() < 0.5f){ if(previous.turnType.getTurnAngle() < 0.5f){
previous.turnType.setTurnAngle(angle); previous.turnType.setTurnAngle(angle);

View file

@ -528,7 +528,7 @@ public class RoutingHelper {
public int getExitOut() { public int getExitOut() {
return exitOut; return exitOut;
} }
public boolean isExit(){ public boolean isRoundAbout(){
return value.equals("EXIT"); //$NON-NLS-1$ return value.equals("EXIT"); //$NON-NLS-1$
} }
} }

View file

@ -43,13 +43,15 @@ import com.osmand.voice.CommandPlayer.CommandBuilder;
public class ShowRouteInfoActivity extends ListActivity { public class ShowRouteInfoActivity extends ListActivity {
private RoutingHelper helper;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
ListView lv = new ListView(this); ListView lv = new ListView(this);
lv.setId(android.R.id.list); lv.setId(android.R.id.list);
TextView header = new TextView(this); TextView header = new TextView(this);
RoutingHelper helper = RoutingHelper.getInstance(this); helper = RoutingHelper.getInstance(this);
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
int time = helper.getLeftTime() * 1000 - c.getTimeZone().getOffset(0); int time = helper.getLeftTime() * 1000 - c.getTimeZone().getOffset(0);
int dist = helper.getLeftDistance(); int dist = helper.getLeftDistance();
@ -62,11 +64,9 @@ public class ShowRouteInfoActivity extends ListActivity {
public void onListItemClick(ListView parent, View v, int position, long id) { public void onListItemClick(ListView parent, View v, int position, long id) {
RouteDirectionInfo item = ((RouteInfoAdapter)getListAdapter()).getItem(position - 1); RouteDirectionInfo item = ((RouteInfoAdapter)getListAdapter()).getItem(position - 1);
RoutingHelper inst = RoutingHelper.getInstance(this); Location loc = helper.getLocationFromRouteDirection(item);
Location loc = inst.getLocationFromRouteDirection(item);
CommandPlayer player = CommandPlayer.getInstance(this); CommandPlayer player = CommandPlayer.getInstance(this);
if(player != null){ if(player != null){
// TODO temp solution roundabout
CommandBuilder builder = player.newCommandBuilder(); CommandBuilder builder = player.newCommandBuilder();
if(item.turnType.getValue() == TurnType.C){ if(item.turnType.getValue() == TurnType.C){
builder.goAhead(item.distance); builder.goAhead(item.distance);
@ -84,6 +84,8 @@ public class ShowRouteInfoActivity extends ListActivity {
builder.turnSLRight(item.distance); builder.turnSLRight(item.distance);
} else if(item.turnType.getValue() == TurnType.TSHR) { } else if(item.turnType.getValue() == TurnType.TSHR) {
builder.turnSHRight(item.distance); builder.turnSHRight(item.distance);
} else if(item.turnType.isRoundAbout()) {
builder.roundAbout(item.distance, item.turnType.getExitOut());
} }
builder.play(); builder.play();
} }

View file

@ -381,7 +381,7 @@ public class MapInfoLayer implements OsmandMapLayer {
pathForTurn.rQuadTo(0, -quadShiftX, quadShiftX, -quadShiftY); pathForTurn.rQuadTo(0, -quadShiftX, quadShiftX, -quadShiftY);
pathForTurn.rQuadTo(quadShiftX, 0, quadShiftX, quadShiftY); pathForTurn.rQuadTo(quadShiftX, 0, quadShiftX, quadShiftY);
pathForTurn.rLineTo(0, h); pathForTurn.rLineTo(0, h);
} else if (turnType != null && turnType.isExit()) { } else if (turnType != null && turnType.isRoundAbout()) {
float t = turnType.getTurnAngle(); float t = turnType.getTurnAngle();
if (t >= 170 && t < 220) { if (t >= 170 && t < 220) {
t = 220; t = 220;

View file

@ -243,7 +243,9 @@ public class CommandPlayer {
protected static final String A_RIGHT_SL = "right_sl"; //$NON-NLS-1$ protected static final String A_RIGHT_SL = "right_sl"; //$NON-NLS-1$
protected static final String С_PREPARE_TURN = "prepare_turn"; //$NON-NLS-1$ protected static final String С_PREPARE_TURN = "prepare_turn"; //$NON-NLS-1$
protected static final String С_PREPARE_ROUNDABOUT = "prepare_roundabout"; //$NON-NLS-1$
protected static final String С_PREPARE_MAKE_UT = "prepare_make_ut"; //$NON-NLS-1$ protected static final String С_PREPARE_MAKE_UT = "prepare_make_ut"; //$NON-NLS-1$
protected static final String С_ROUNDABOUT = "roundabout"; //$NON-NLS-1$
protected static final String С_GO_AHEAD = "go_ahead"; //$NON-NLS-1$ protected static final String С_GO_AHEAD = "go_ahead"; //$NON-NLS-1$
protected static final String С_TURN = "turn"; //$NON-NLS-1$ protected static final String С_TURN = "turn"; //$NON-NLS-1$
protected static final String С_MAKE_UT = "make_ut"; //$NON-NLS-1$ protected static final String С_MAKE_UT = "make_ut"; //$NON-NLS-1$
@ -393,6 +395,18 @@ public class CommandPlayer {
public CommandBuilder prepareTurnSHRight(double dist){ public CommandBuilder prepareTurnSHRight(double dist){
return addCommand(С_PREPARE_TURN, A_RIGHT_SH, dist); return addCommand(С_PREPARE_TURN, A_RIGHT_SH, dist);
} }
public CommandBuilder prepareRoundAbout(double dist){
return addCommand(С_PREPARE_ROUNDABOUT, dist);
}
public CommandBuilder roundAbout(double dist, int exit){
return addCommand(С_ROUNDABOUT, dist, exit);
}
public CommandBuilder roundAbout(int exit){
return addCommand(С_ROUNDABOUT, exit);
}