Source layer

This commit is contained in:
Victor Shcherb 2015-01-25 22:23:49 +01:00
parent d6d63e1cb2
commit d3f6b65b56
3 changed files with 33 additions and 17 deletions

View file

@ -337,7 +337,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
tx.add(x);
ty.add(y);
}
calculatePath(tb, tx, ty, path);
calculatePath(tb, tx, ty, path, null);
if(isPaint_1) {
canvas.drawPath(path, paint_1);
}

View file

@ -2,6 +2,7 @@ package net.osmand.plus.views;
import gnu.trove.list.array.TIntArrayList;
import java.util.List;
import java.util.Map;
import net.osmand.data.RotatedTileBox;
@ -78,41 +79,48 @@ public abstract class OsmandMapLayer {
return x >= lx && x <= rx && y >= ty && y <= by;
}
public void calculatePath(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys, Path path) {
public int calculatePath(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys, Path path, List<Path> createNewAdditionalPath) {
boolean start = false;
int px = xs.get(0);
int py = ys.get(0);
int h = tb.getPixHeight();
int w = tb.getPixWidth();
int cnt = 0;
boolean pin = isIn(px, py, 0, 0, w, h);
for(int i = 1; i < xs.size(); i++) {
int x = xs.get(i);
int y = ys.get(i);
boolean in = isIn(x, y, 0, 0, w, h);
boolean draw = false;
if(pin && in) {
if(!start) {
draw = true;
} else {
long intersection = MapAlgorithms.calculateIntersection(x, y,
px, py, 0, w, h, 0);
if (intersection != -1) {
px = (int) (intersection >> 32);
py = (int) (intersection & 0xffffffff);
}
}
if (draw) {
if (!start) {
if (createNewAdditionalPath != null) {
path = new Path();
createNewAdditionalPath.add(path);
}
cnt++;
path.moveTo(px, py);
}
path.lineTo(x, y);
start = true;
} else{
long intersection = MapAlgorithms.calculateIntersection(x, y, px, py, 0, w, h, 0);
if(intersection != -1) {
int bx = (int) (intersection >> 32);
int by = (int) (intersection & 0xffffffff);
if(!start) {
path.moveTo(bx, by);
}
path.lineTo(x, y);
start = true;
} else {
start = false;
}
start = false;
}
pin = in;
px = x;
py = y;
}
return cnt;
}

View file

@ -173,7 +173,7 @@ public class RouteLayer extends OsmandMapLayer {
tx.add(x);
ty.add(y);
}
calculatePath(tb, tx, ty, path);
int pth = calculatePath(tb, tx, ty, path, null);
if(isPaint_1) {
canvas.drawPath(path, paint_1);
@ -186,7 +186,15 @@ public class RouteLayer extends OsmandMapLayer {
canvas.drawPath(path, paint2);
}
if(tb.getZoomAnimation() == 0) {
drawArrowsOverPath(canvas, path, coloredArrowUp);
if(pth <= 1) {
drawArrowsOverPath(canvas, path, coloredArrowUp);
} else {
ArrayList<Path> lst = new ArrayList<Path>();
calculatePath(tb, tx, ty, path, lst);
for(Path l : lst) {
drawArrowsOverPath(canvas, l, coloredArrowUp);
}
}
}
}
}