Left side countries roundabout

This commit is contained in:
Victor Shcherb 2012-06-24 11:42:23 +02:00
parent fff6be1a17
commit c0e72be99b
2 changed files with 30 additions and 14 deletions

View file

@ -502,23 +502,24 @@ public class MapInfoLayer extends OsmandMapLayer {
// final int exits = 5; // final int exits = 5;
// i++; // i++;
// if (i % (l + exits) >= l ) { // 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)+""; // nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+"";
// float a = 180 - (i % (l + exits) - l + 1) * 50; // float a = 180 - (i % (l + exits) - l + 1) * 50;
// nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a); // nextTurnInfo.turnType.setTurnAngle(a < 0 ? a + 360 : a);
// } else { // } 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.exitOut = "";
// } // }
// nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3; // nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3;
// nextTurnInfo.nextTurnDirection = 580; // nextTurnInfo.nextTurnDirection = 580;
// TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nextTurnInfo.turnType,nextTurnInfo.pathTransform); // TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nexsweepAngletTurnInfo.turnType,nextTurnInfo.pathTransform);
showMiniMap = true;
// showMiniMap = true;
view.refreshMap(); view.refreshMap();
} }
}); });
// initial state // initial state
nextTurnInfo.setVisibility(View.GONE); // nextTurnInfo.setVisibility(View.GONE);
return nextTurnInfo; return nextTurnInfo;
} }
@ -576,6 +577,7 @@ public class MapInfoLayer extends OsmandMapLayer {
}; };
nextTurnInfo.setOnClickListener(new View.OnClickListener() { nextTurnInfo.setOnClickListener(new View.OnClickListener() {
// int i = 0; // int i = 0;
// boolean leftSide = false;
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// for test rendering purposes // for test rendering purposes
@ -583,12 +585,12 @@ public class MapInfoLayer extends OsmandMapLayer {
// final int exits = 5; // final int exits = 5;
// i++; // i++;
// if (i % (l + exits) >= l ) { // 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), leftSide);
// float a = 180 - (i % (l + exits) - l + 1) * 50; // 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.turnType.setTurnAngle(a < 0 ? a + 360 : a);
// nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+""; // nextTurnInfo.exitOut = (i % (l + exits) - l + 1)+"";
// } else { // } 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.exitOut = "";
// } // }
// nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3; // nextTurnInfo.turnImminent = (nextTurnInfo.turnImminent + 1) % 3;

View file

@ -157,18 +157,27 @@ public class TurnPathHelper {
} else if (t > 160 && t < 170) { } else if (t > 160 && t < 170) {
t = 160; t = 160;
} }
boolean leftSide = turnType.isLeftSide();
float sweepAngle = (t - 360) - 180; float sweepAngle = (t - 360) - 180;
if (sweepAngle < -360) { if (sweepAngle < -360) {
sweepAngle += 360; sweepAngle += 360;
} }
if(leftSide && sweepAngle < 0) {
sweepAngle += 360;
}
float r1 = ha / 3f - 1; float r1 = ha / 3f - 1;
float r2 = r1 - 9; float r2 = r1 - 9;
float angleToRot = 0.3f; float angleToRot = leftSide ? -0.3f : 0.3f;
int cx = wa / 2 ; int cx = wa / 2 ;
int cy = ha / 2 - 2; int cy = ha / 2 - 2;
pathForTurn.moveTo(cx, ha - 1); if (leftSide) {
pathForTurn.lineTo(cx, cy + r1); 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); RectF r = new RectF(cx - r1, cy - r1, cx + r1, cy + r1);
int out = turnType.getExitOut(); int out = turnType.getExitOut();
@ -177,8 +186,8 @@ public class TurnPathHelper {
} }
float prev = 90; float prev = 90;
float init = 90; float init = 90;
float step = sweepAngle / out; float step = sweepAngle / out;
boolean leftSide = turnType.isLeftSide();
for (int i = 1; i <= out; i++) { for (int i = 1; i <= out; i++) {
float to = step * i; float to = step * i;
if (i == out) { if (i == out) {
@ -206,8 +215,13 @@ public class TurnPathHelper {
r.set(cx - r2, cy - r2, cx + r2, cy + r2); r.set(cx - r2, cy - r2, cx + r2, cy + r2);
pathForTurn.arcTo(r, 360 + sweepAngle + 90, -sweepAngle); pathForTurn.arcTo(r, 360 + sweepAngle + 90, -sweepAngle);
pathForTurn.lineTo(cx - 8, cy + r2); if (leftSide) {
pathForTurn.lineTo(cx - 8, ha - 1); 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();
} }
pathForTurn.close(); pathForTurn.close();