diff --git a/OsmAnd/src/com/osmand/activities/RouteProvider.java b/OsmAnd/src/com/osmand/activities/RouteProvider.java index 9ab850996f..0990bcaad9 100644 --- a/OsmAnd/src/com/osmand/activities/RouteProvider.java +++ b/OsmAnd/src/com/osmand/activities/RouteProvider.java @@ -499,17 +499,21 @@ public class RouteProvider { if(previous.routePointOffset > 0){ float paz = res.get(previous.routePointOffset - 1).bearingTo(res.get(previous.routePointOffset)); 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)); } else { 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){ angle += 360; } else if(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){ previous.turnType.setTurnAngle(angle); diff --git a/OsmAnd/src/com/osmand/activities/RoutingHelper.java b/OsmAnd/src/com/osmand/activities/RoutingHelper.java index 921855d59f..c6a0cc991f 100644 --- a/OsmAnd/src/com/osmand/activities/RoutingHelper.java +++ b/OsmAnd/src/com/osmand/activities/RoutingHelper.java @@ -528,7 +528,7 @@ public class RoutingHelper { public int getExitOut() { return exitOut; } - public boolean isExit(){ + public boolean isRoundAbout(){ return value.equals("EXIT"); //$NON-NLS-1$ } } diff --git a/OsmAnd/src/com/osmand/activities/ShowRouteInfoActivity.java b/OsmAnd/src/com/osmand/activities/ShowRouteInfoActivity.java index a07b6d8fab..3f86559a3a 100644 --- a/OsmAnd/src/com/osmand/activities/ShowRouteInfoActivity.java +++ b/OsmAnd/src/com/osmand/activities/ShowRouteInfoActivity.java @@ -43,13 +43,15 @@ import com.osmand.voice.CommandPlayer.CommandBuilder; public class ShowRouteInfoActivity extends ListActivity { + private RoutingHelper helper; + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); ListView lv = new ListView(this); lv.setId(android.R.id.list); TextView header = new TextView(this); - RoutingHelper helper = RoutingHelper.getInstance(this); + helper = RoutingHelper.getInstance(this); Calendar c = Calendar.getInstance(); int time = helper.getLeftTime() * 1000 - c.getTimeZone().getOffset(0); int dist = helper.getLeftDistance(); @@ -62,11 +64,9 @@ public class ShowRouteInfoActivity extends ListActivity { public void onListItemClick(ListView parent, View v, int position, long id) { RouteDirectionInfo item = ((RouteInfoAdapter)getListAdapter()).getItem(position - 1); - RoutingHelper inst = RoutingHelper.getInstance(this); - Location loc = inst.getLocationFromRouteDirection(item); + Location loc = helper.getLocationFromRouteDirection(item); CommandPlayer player = CommandPlayer.getInstance(this); if(player != null){ - // TODO temp solution roundabout CommandBuilder builder = player.newCommandBuilder(); if(item.turnType.getValue() == TurnType.C){ builder.goAhead(item.distance); @@ -84,6 +84,8 @@ public class ShowRouteInfoActivity extends ListActivity { builder.turnSLRight(item.distance); } else if(item.turnType.getValue() == TurnType.TSHR) { builder.turnSHRight(item.distance); + } else if(item.turnType.isRoundAbout()) { + builder.roundAbout(item.distance, item.turnType.getExitOut()); } builder.play(); } diff --git a/OsmAnd/src/com/osmand/views/MapInfoLayer.java b/OsmAnd/src/com/osmand/views/MapInfoLayer.java index 49ba094635..5bdba61387 100644 --- a/OsmAnd/src/com/osmand/views/MapInfoLayer.java +++ b/OsmAnd/src/com/osmand/views/MapInfoLayer.java @@ -381,7 +381,7 @@ public class MapInfoLayer implements OsmandMapLayer { pathForTurn.rQuadTo(0, -quadShiftX, quadShiftX, -quadShiftY); pathForTurn.rQuadTo(quadShiftX, 0, quadShiftX, quadShiftY); pathForTurn.rLineTo(0, h); - } else if (turnType != null && turnType.isExit()) { + } else if (turnType != null && turnType.isRoundAbout()) { float t = turnType.getTurnAngle(); if (t >= 170 && t < 220) { t = 220; diff --git a/OsmAnd/src/com/osmand/voice/CommandPlayer.java b/OsmAnd/src/com/osmand/voice/CommandPlayer.java index 04b74f4c9d..6222b41d1f 100644 --- a/OsmAnd/src/com/osmand/voice/CommandPlayer.java +++ b/OsmAnd/src/com/osmand/voice/CommandPlayer.java @@ -243,7 +243,9 @@ public class CommandPlayer { 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_ROUNDABOUT = "prepare_roundabout"; //$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 С_TURN = "turn"; //$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){ 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); + }