Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-05-14 00:45:32 +02:00
commit cdf587d92b
3 changed files with 48 additions and 25 deletions

View file

@ -243,12 +243,12 @@ public class RouteCalculationResult {
if (routeInd < list.size()) { if (routeInd < list.size()) {
int lind = routeInd; int lind = routeInd;
if(turn.isRoundAbout()) { if(turn.isRoundAbout()) {
int roundAboutEnd = prevLocationSize - 1; int roundAboutEnd = prevLocationSize ;
// take next name for roundabout (not roundabout name) // take next name for roundabout (not roundabout name)
while(lind < list.size() -1 && list.get(lind).getObject().roundabout()) { while (lind < list.size() - 1 && list.get(lind).getObject().roundabout()) {
roundAboutEnd += Math.abs(list.get(lind).getEndPointIndex()-list.get(lind).getStartPointIndex()); roundAboutEnd++;
lind++; lind++;
} }
// Consider roundabout end. // Consider roundabout end.
info.routeEndPointOffset = roundAboutEnd; info.routeEndPointOffset = roundAboutEnd;
} }
@ -811,6 +811,7 @@ public class RouteCalculationResult {
!Algorithms.objectEquals(p.getStreetName(), i.getStreetName()))) { !Algorithms.objectEquals(p.getStreetName(), i.getStreetName()))) {
p = new RouteDirectionInfo(i.getAverageSpeed(), i.getTurnType()); p = new RouteDirectionInfo(i.getAverageSpeed(), i.getTurnType());
p.routePointOffset = i.routePointOffset; p.routePointOffset = i.routePointOffset;
p.routeEndPointOffset = i.routeEndPointOffset;
p.setDestinationName(i.getDestinationName()); p.setDestinationName(i.getDestinationName());
p.setRef(i.getRef()); p.setRef(i.getRef());
p.setStreetName(i.getStreetName()); p.setStreetName(i.getStreetName());

View file

@ -428,6 +428,9 @@ public class RouteProvider {
if (info.routePointOffset >= startI[0] && info.routePointOffset < endI[0]) { if (info.routePointOffset >= startI[0] && info.routePointOffset < endI[0]) {
RouteDirectionInfo ch = new RouteDirectionInfo(info.getAverageSpeed(), info.getTurnType()); RouteDirectionInfo ch = new RouteDirectionInfo(info.getAverageSpeed(), info.getTurnType());
ch.routePointOffset = info.routePointOffset - startI[0]; ch.routePointOffset = info.routePointOffset - startI[0];
if(info.routeEndPointOffset != 0) {
ch.routeEndPointOffset = info.routeEndPointOffset - startI[0];
}
ch.setDescriptionRoute(info.getDescriptionRoutePart()); ch.setDescriptionRoute(info.getDescriptionRoutePart());
directions.add(ch); directions.add(ch);
} }

View file

@ -24,6 +24,7 @@ import android.graphics.Color;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Paint.Cap; import android.graphics.Paint.Cap;
import android.graphics.Paint.Join; import android.graphics.Paint.Join;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
@ -57,6 +58,7 @@ public class RouteLayer extends OsmandMapLayer {
private Bitmap actionArrow; private Bitmap actionArrow;
private Paint paintIcon; private Paint paintIcon;
private Paint paintIconAction;
private OsmandRenderer osmandRenderer; private OsmandRenderer osmandRenderer;
@ -79,7 +81,7 @@ public class RouteLayer extends OsmandMapLayer {
actionPaint.setAntiAlias(true); actionPaint.setAntiAlias(true);
actionPaint.setStrokeCap(Cap.BUTT); actionPaint.setStrokeCap(Cap.BUTT);
actionPaint.setStrokeJoin(Join.ROUND); actionPaint.setStrokeJoin(Join.ROUND);
actionPaint.setStrokeWidth(7 * view.getDensity()); actionPaint.setStrokeWidth(7 * view.getScaleCoefficient());
actionPaint.setColor(Color.WHITE); actionPaint.setColor(Color.WHITE);
path = new Path(); path = new Path();
@ -89,6 +91,11 @@ public class RouteLayer extends OsmandMapLayer {
paintIcon.setColor(Color.BLACK); paintIcon.setColor(Color.BLACK);
paintIcon.setStrokeWidth(3); paintIcon.setStrokeWidth(3);
paintIconAction = new Paint();
paintIconAction.setFilterBitmap(true);
paintIconAction.setAntiAlias(true);
} }
@Override @Override
@ -119,8 +126,9 @@ public class RouteLayer extends OsmandMapLayer {
} }
osmandRenderer.updatePaint(req, actionPaint, 2, false, rc); osmandRenderer.updatePaint(req, actionPaint, 2, false, rc);
// TODO remove // TODO remove
actionPaint.setStrokeWidth(7 * view.getDensity()); // actionPaint.setColor(Color.BLUE);
actionPaint.setColor(Color.WHITE); paintIconAction.setColorFilter(new PorterDuffColorFilter(actionPaint.getColor(), Mode.MULTIPLY));
isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc); isPaint2 = osmandRenderer.updatePaint(req, paint2, 1, false, rc);
isPaint_1 = osmandRenderer.updatePaint(req, paint_1, -1, false, rc); isPaint_1 = osmandRenderer.updatePaint(req, paint_1, -1, false, rc);
isShadowPaint = req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS); isShadowPaint = req.isSpecified(rrs.PROPS.R_SHADOW_RADIUS);
@ -132,8 +140,8 @@ public class RouteLayer extends OsmandMapLayer {
} else { } else {
System.err.println("Rendering attribute route is not found !"); System.err.println("Rendering attribute route is not found !");
paint.setStrokeWidth(12 * view.getDensity()); 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); Location o = actionPoints.get(i);
if (o == null) { if (o == null) {
canvas.drawPath(pth, actionPaint); canvas.drawPath(pth, actionPaint);
float angleRad = (float) Math.atan2(y - py, x - px); double angleRad = Math.atan2(y - py, x - px);
float angle = (float) (angleRad * 180 / Math.PI) + 90f; double angle = (angleRad * 180 / Math.PI) + 90f;
float distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px)); double distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px));
if (distSegment == 0) { if (distSegment == 0) {
continue; continue;
} }
@ -203,9 +211,9 @@ public class RouteLayer extends OsmandMapLayer {
float pdy = y - py; float pdy = y - py;
matrix.reset(); matrix.reset();
matrix.postTranslate(0, -actionArrow.getHeight() / 2); 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); matrix.postTranslate(px + pdx - actionArrow.getWidth() / 2, py + pdy);
canvas.drawBitmap(actionArrow, matrix, paintIcon); canvas.drawBitmap(actionArrow, matrix, paintIconAction);
first = true; first = true;
} else { } else {
px = x; px = x;
@ -343,7 +351,7 @@ public class RouteLayer extends OsmandMapLayer {
drawSegment(tb, canvas); drawSegment(tb, canvas);
if (tb.getZoom() >= 14) { if (tb.getZoom() >= 14) {
calculateActionPoints(topLatitude, leftLongitude, bottomLatitude, rightLongitude, lastProjection, calculateActionPoints(topLatitude, leftLongitude, bottomLatitude, rightLongitude, lastProjection,
routeNodes, cd, it); routeNodes, cd, it, tb.getZoom());
drawAction(tb, canvas); drawAction(tb, canvas);
} }
} }
@ -351,24 +359,30 @@ public class RouteLayer extends OsmandMapLayer {
private void calculateActionPoints(double topLatitude, double leftLongitude, double bottomLatitude, private void calculateActionPoints(double topLatitude, double leftLongitude, double bottomLatitude,
double rightLongitude, Location lastProjection, List<Location> routeNodes, int cd, double rightLongitude, Location lastProjection, List<Location> routeNodes, int cd,
Iterator<RouteDirectionInfo> it) { Iterator<RouteDirectionInfo> it, int zoom) {
RouteDirectionInfo nf = null; RouteDirectionInfo nf = null;
double DISTANCE_ACTION = 35; double DISTANCE_ACTION = zoom >= 17 ? 15 : 35;
double actionDist = 0; double actionDist = 0;
Location previousAction = null; Location previousAction = null;
actionPoints.clear(); actionPoints.clear();
int prevPoint = -2;
for (int i = 0; i < routeNodes.size(); i++) { for (int i = 0; i < routeNodes.size(); i++) {
Location ls = routeNodes.get(i); Location ls = routeNodes.get(i);
if(nf != null && nf.routePointOffset < i + cd) { if(nf != null) {
nf = null; int pnt = nf.routeEndPointOffset == 0 ? nf.routePointOffset : nf.routeEndPointOffset;
} if(pnt < i + cd ) {
while (nf == null && it.hasNext()) {
nf = it.next();
if (nf.routePointOffset < i + cd) {
nf = null; 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) { if(!action && previousAction == null) {
continue; continue;
} }
@ -379,8 +393,8 @@ public class RouteLayer extends OsmandMapLayer {
float loc = ls.distanceTo(previousAction); float loc = ls.distanceTo(previousAction);
actionDist += loc; actionDist += loc;
if(actionDist >= DISTANCE_ACTION) { if(actionDist >= DISTANCE_ACTION) {
// calculate distance proj?
actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / loc, previousAction, ls)); actionPoints.add(calculateProjection(1 - (actionDist - DISTANCE_ACTION) / loc, previousAction, ls));
prevPoint = i;
actionPoints.add(null); actionPoints.add(null);
previousAction = null; previousAction = null;
actionDist = 0; actionDist = 0;
@ -407,6 +421,11 @@ public class RouteLayer extends OsmandMapLayer {
} }
break; break;
} else { } else {
if(prevPoint == k) {
actionPoints.remove(ind - 1);
actionPoints.remove(ind - 1);
prevPoint = -2;
}
actionPoints.add(ind, l); actionPoints.add(ind, l);
lp = l; lp = l;
} }