Fix turn bug

This commit is contained in:
Alexander Sytnyk 2017-07-27 16:08:52 +03:00
parent 2624ecaef0
commit 451ebba12e

View file

@ -205,8 +205,8 @@ public class RulerControlLayer extends OsmandMapLayer {
drawCenterIcon(canvas, tb, center, settings.isNightMode(), mode); drawCenterIcon(canvas, tb, center, settings.isNightMode(), mode);
Location currentLoc = app.getLocationProvider().getLastKnownLocation(); Location currentLoc = app.getLocationProvider().getLastKnownLocation();
if (showDistBetweenFingerAndLocation && currentLoc != null) { if (showDistBetweenFingerAndLocation && currentLoc != null) {
float x = tb.getPixXFromLonNoRot(touchPointLatLon.getLongitude()); float x = tb.getPixXFromLatLon(touchPointLatLon.getLatitude(), touchPointLatLon.getLongitude());
float y = tb.getPixYFromLatNoRot(touchPointLatLon.getLatitude()); float y = tb.getPixYFromLatLon(touchPointLatLon.getLatitude(), touchPointLatLon.getLongitude());
drawDistBetweenFingerAndLocation(canvas, tb, x, y, currentLoc, settings.isNightMode()); drawDistBetweenFingerAndLocation(canvas, tb, x, y, currentLoc, settings.isNightMode());
} else if (showTwoFingersDistance) { } else if (showTwoFingersDistance) {
LatLon firstTouchPoint = view.getFirstTouchPointLatLon(); LatLon firstTouchPoint = view.getFirstTouchPointLatLon();
@ -272,21 +272,31 @@ public class RulerControlLayer extends OsmandMapLayer {
private void drawDistBetweenFingerAndLocation(Canvas canvas, RotatedTileBox tb, float x, float y, private void drawDistBetweenFingerAndLocation(Canvas canvas, RotatedTileBox tb, float x, float y,
Location currentLoc, boolean nightMode) { Location currentLoc, boolean nightMode) {
int currX = tb.getPixXFromLonNoRot(currentLoc.getLongitude()); int currX = (int) tb.getPixXFromLatLon(currentLoc.getLatitude(), currentLoc.getLongitude());
int currY = tb.getPixYFromLatNoRot(currentLoc.getLatitude()); int currY = (int) tb.getPixYFromLatLon(currentLoc.getLatitude(), currentLoc.getLongitude());
distancePath.reset(); int width = tb.getPixWidth();
tx.clear(); int height = tb.getPixHeight();
ty.clear();
tx.add(currX); if (currX < 0 || currY < 0 || currX > width || currY > height) {
ty.add(currY); float xNew = (currX + x) / 2;
tx.add((int) x); float yNew = (currY + y) / 2;
ty.add((int) y);
calculatePath(tb, tx, ty, distancePath); while (true) {
canvas.drawPath(distancePath, lineAttrs.paint); if (xNew < 0 || yNew < 0 || xNew > width || yNew > height) {
// canvas.drawLine(currX, currY, x, y, lineAttrs.paint); currX = (int) xNew;
currY = (int) yNew;
} else {
break;
}
xNew = (xNew + x) / 2;
yNew = (yNew + y) / 2;
}
}
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
canvas.drawLine(currX, currY, x, y, lineAttrs.paint);
drawFingerTouchIcon(canvas, x, y, nightMode); drawFingerTouchIcon(canvas, x, y, nightMode);
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
} }
private void updateData(RotatedTileBox tb, QuadPoint center) { private void updateData(RotatedTileBox tb, QuadPoint center) {