From c0e72be99b75740b282c888daeb13092c3c518ac Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 24 Jun 2012 11:42:23 +0200 Subject: [PATCH] Left side countries roundabout --- .../net/osmand/plus/views/MapInfoLayer.java | 18 +++++++------ .../net/osmand/plus/views/TurnPathHelper.java | 26 ++++++++++++++----- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 88b14a5147..9a10eedfd6 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -502,23 +502,24 @@ public class MapInfoLayer extends OsmandMapLayer { // final int exits = 5; // i++; // if (i % (l + exits) >= l ) { -// nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1)); +// nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1), true); // nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+""; // float a = 180 - (i % (l + exits) - l + 1) * 50; // nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a); // } else { -// nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % (TurnType.predefinedTypes.length + exits)]); +// nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % (TurnType.predefinedTypes.length + exits)], true); // nextTurnInfo.exitOut = ""; // } // nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3; // nextTurnInfo.nextTurnDirection = 580; -// TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nextTurnInfo.turnType,nextTurnInfo.pathTransform); - showMiniMap = true; +// TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nexsweepAngletTurnInfo.turnType,nextTurnInfo.pathTransform); + +// showMiniMap = true; view.refreshMap(); } }); // initial state - nextTurnInfo.setVisibility(View.GONE); +// nextTurnInfo.setVisibility(View.GONE); return nextTurnInfo; } @@ -576,6 +577,7 @@ public class MapInfoLayer extends OsmandMapLayer { }; nextTurnInfo.setOnClickListener(new View.OnClickListener() { // int i = 0; +// boolean leftSide = false; @Override public void onClick(View v) { // for test rendering purposes @@ -583,12 +585,12 @@ public class MapInfoLayer extends OsmandMapLayer { // final int exits = 5; // i++; // if (i % (l + exits) >= l ) { -// nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1)); -// float a = 180 - (i % (l + exits) - l + 1) * 50; +// nextTurnInfo.turnType = TurnType.valueOf("EXIT" + (i % (l + exits) - l + 1), leftSide); +// float a = leftSide? -180 + (i % (l + exits) - l + 1) * 50: 180 - (i % (l + exits) - l + 1) * 50; // nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a); // nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+""; // } else { -// nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % (TurnType.predefinedTypes.length + exits)]); +// nextTurnInfo.turnType = TurnType.valueOf(TurnType.predefinedTypes[i % (TurnType.predefinedTypes.length + exits)], leftSide); // nextTurnInfo.exitOut = ""; // } // nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3; diff --git a/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java b/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java index e1d97f9d89..31b328c1c7 100644 --- a/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java @@ -157,18 +157,27 @@ public class TurnPathHelper { } else if (t > 160 && t < 170) { t = 160; } + boolean leftSide = turnType.isLeftSide(); float sweepAngle = (t - 360) - 180; if (sweepAngle < -360) { sweepAngle += 360; } + if(leftSide && sweepAngle < 0) { + sweepAngle += 360; + } float r1 = ha / 3f - 1; float r2 = r1 - 9; - float angleToRot = 0.3f; + float angleToRot = leftSide ? -0.3f : 0.3f; int cx = wa / 2 ; int cy = ha / 2 - 2; - pathForTurn.moveTo(cx, ha - 1); - pathForTurn.lineTo(cx, cy + r1); + if (leftSide) { + pathForTurn.moveTo(cx - 8, ha - 1); + pathForTurn.lineTo(cx - 8, cy + r1); + } else { + pathForTurn.moveTo(cx, ha - 1); + pathForTurn.lineTo(cx, cy + r1); + } RectF r = new RectF(cx - r1, cy - r1, cx + r1, cy + r1); int out = turnType.getExitOut(); @@ -177,8 +186,8 @@ public class TurnPathHelper { } float prev = 90; float init = 90; + float step = sweepAngle / out; - boolean leftSide = turnType.isLeftSide(); for (int i = 1; i <= out; i++) { float to = step * i; if (i == out) { @@ -206,8 +215,13 @@ public class TurnPathHelper { r.set(cx - r2, cy - r2, cx + r2, cy + r2); pathForTurn.arcTo(r, 360 + sweepAngle + 90, -sweepAngle); - pathForTurn.lineTo(cx - 8, cy + r2); - pathForTurn.lineTo(cx - 8, ha - 1); + if (leftSide) { + pathForTurn.lineTo(cx, cy + r2); + pathForTurn.lineTo(cx, ha - 1); + } else { + pathForTurn.lineTo(cx - 8, cy + r2); + pathForTurn.lineTo(cx - 8, ha - 1); + } pathForTurn.close(); } pathForTurn.close();