diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 6631d2cd13..9371f8b120 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -243,12 +243,12 @@ public class RouteCalculationResult { if (routeInd < list.size()) { int lind = routeInd; if(turn.isRoundAbout()) { - int roundAboutEnd = prevLocationSize - 1; + int roundAboutEnd = prevLocationSize ; // take next name for roundabout (not roundabout name) - while(lind < list.size() -1 && list.get(lind).getObject().roundabout()) { - roundAboutEnd += Math.abs(list.get(lind).getEndPointIndex()-list.get(lind).getStartPointIndex()); - lind++; - } + while (lind < list.size() - 1 && list.get(lind).getObject().roundabout()) { + roundAboutEnd++; + lind++; + } // Consider roundabout end. info.routeEndPointOffset = roundAboutEnd; } @@ -811,6 +811,7 @@ public class RouteCalculationResult { !Algorithms.objectEquals(p.getStreetName(), i.getStreetName()))) { p = new RouteDirectionInfo(i.getAverageSpeed(), i.getTurnType()); p.routePointOffset = i.routePointOffset; + p.routeEndPointOffset = i.routeEndPointOffset; p.setDestinationName(i.getDestinationName()); p.setRef(i.getRef()); p.setStreetName(i.getStreetName()); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 7ebda89056..c64e6ba048 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -428,6 +428,9 @@ public class RouteProvider { if (info.routePointOffset >= startI[0] && info.routePointOffset < endI[0]) { RouteDirectionInfo ch = new RouteDirectionInfo(info.getAverageSpeed(), info.getTurnType()); ch.routePointOffset = info.routePointOffset - startI[0]; + if(info.routeEndPointOffset != 0) { + ch.routeEndPointOffset = info.routeEndPointOffset - startI[0]; + } ch.setDescriptionRoute(info.getDescriptionRoutePart()); directions.add(ch); } diff --git a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java index 1d0d3562b6..b89b74b281 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java @@ -24,6 +24,7 @@ import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.PorterDuff; import android.graphics.Paint.Cap; import android.graphics.Paint.Join; import android.graphics.Paint.Style; @@ -57,6 +58,7 @@ public class RouteLayer extends OsmandMapLayer { private Bitmap actionArrow; private Paint paintIcon; + private Paint paintIconAction; private OsmandRenderer osmandRenderer; @@ -79,7 +81,7 @@ public class RouteLayer extends OsmandMapLayer { actionPaint.setAntiAlias(true); actionPaint.setStrokeCap(Cap.BUTT); actionPaint.setStrokeJoin(Join.ROUND); - actionPaint.setStrokeWidth(7 * view.getDensity()); + actionPaint.setStrokeWidth(7 * view.getScaleCoefficient()); actionPaint.setColor(Color.WHITE); path = new Path(); @@ -89,6 +91,11 @@ public class RouteLayer extends OsmandMapLayer { paintIcon.setColor(Color.BLACK); paintIcon.setStrokeWidth(3); + + paintIconAction = new Paint(); + paintIconAction.setFilterBitmap(true); + paintIconAction.setAntiAlias(true); + } @Override @@ -119,8 +126,9 @@ public class RouteLayer extends OsmandMapLayer { } osmandRenderer.updatePaint(req, actionPaint, 2, false, rc); // TODO remove - actionPaint.setStrokeWidth(7 * view.getDensity()); - actionPaint.setColor(Color.WHITE); + // actionPaint.setColor(Color.BLUE); + paintIconAction.setColorFilter(new PorterDuffColorFilter(actionPaint.getColor(), Mode.MULTIPLY)); + isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); isPaint_1 = osmandRenderer.updatePaint(req, paint_1, -1, false, rc); isShadowPaint = req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS); @@ -132,8 +140,8 @@ public class RouteLayer extends OsmandMapLayer { } else { System.err.println("Rendering attribute route is not found !"); paint.setStrokeWidth(12 * view.getDensity()); - actionPaint.setStrokeWidth(7 * view.getDensity()); } + actionPaint.setStrokeWidth(7 * view.getScaleCoefficient()); } } } @@ -192,9 +200,9 @@ public class RouteLayer extends OsmandMapLayer { Location o = actionPoints.get(i); if (o == null) { canvas.drawPath(pth, actionPaint); - float angleRad = (float) Math.atan2(y - py, x - px); - float angle = (float) (angleRad * 180 / Math.PI) + 90f; - float distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px)); + double angleRad = Math.atan2(y - py, x - px); + double angle = (angleRad * 180 / Math.PI) + 90f; + double distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px)); if (distSegment == 0) { continue; } @@ -203,9 +211,9 @@ public class RouteLayer extends OsmandMapLayer { float pdy = y - py; matrix.reset(); matrix.postTranslate(0, -actionArrow.getHeight() / 2); - matrix.postRotate(angle, actionArrow.getWidth() / 2, 0); + matrix.postRotate((float) angle, actionArrow.getWidth() / 2, 0); matrix.postTranslate(px + pdx - actionArrow.getWidth() / 2, py + pdy); - canvas.drawBitmap(actionArrow, matrix, paintIcon); + canvas.drawBitmap(actionArrow, matrix, paintIconAction); first = true; } else { px = x; @@ -343,7 +351,7 @@ public class RouteLayer extends OsmandMapLayer { drawSegment(tb, canvas); if (tb.getZoom() >= 14) { calculateActionPoints(topLatitude, leftLongitude, bottomLatitude, rightLongitude, lastProjection, - routeNodes, cd, it); + routeNodes, cd, it, tb.getZoom()); drawAction(tb, canvas); } } @@ -351,24 +359,30 @@ public class RouteLayer extends OsmandMapLayer { private void calculateActionPoints(double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude, Location lastProjection, List routeNodes, int cd, - Iterator it) { + Iterator it, int zoom) { RouteDirectionInfo nf = null; - double DISTANCE_ACTION = 35; + double DISTANCE_ACTION = zoom >= 17 ? 15 : 35; double actionDist = 0; Location previousAction = null; actionPoints.clear(); + int prevPoint = -2; for (int i = 0; i < routeNodes.size(); i++) { Location ls = routeNodes.get(i); - if(nf != null && nf.routePointOffset < i + cd) { - nf = null; - } - while (nf == null && it.hasNext()) { - nf = it.next(); - if (nf.routePointOffset < i + cd) { + if(nf != null) { + int pnt = nf.routeEndPointOffset == 0 ? nf.routePointOffset : nf.routeEndPointOffset; + if(pnt < i + cd ) { nf = null; } } - boolean action = nf != null && nf.routePointOffset == i + cd; + while (nf == null && it.hasNext()) { + nf = it.next(); + int pnt = nf.routeEndPointOffset == 0 ? nf.routePointOffset : nf.routeEndPointOffset; + if (pnt < i + cd) { + nf = null; + } + } + boolean action = nf != null && (nf.routePointOffset == i + cd || + (nf.routePointOffset <= i + cd && i + cd <= nf.routeEndPointOffset)); if(!action && previousAction == null) { continue; } @@ -379,8 +393,8 @@ public class RouteLayer extends OsmandMapLayer { float loc = ls.distanceTo(previousAction); actionDist += loc; if(actionDist >= DISTANCE_ACTION) { - // calculate distance proj? actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / loc, previousAction, ls)); + prevPoint = i; actionPoints.add(null); previousAction = null; actionDist = 0; @@ -407,6 +421,11 @@ public class RouteLayer extends OsmandMapLayer { } break; } else { + if(prevPoint == k) { + actionPoints.remove(ind - 1); + actionPoints.remove(ind - 1); + prevPoint = -2; + } actionPoints.add(ind, l); lp = l; }