Fix issues with path; rename variables again
This commit is contained in:
parent
931fe968dd
commit
14908992e4
3 changed files with 26 additions and 32 deletions
|
@ -225,23 +225,19 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
WptPt pt = before.points.get(before.points.size() - 1);
|
||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||
path.moveTo(locX, locY);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
path.lineTo(tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
tx.add(tb.getCenterPixelX());
|
||||
ty.add(tb.getCenterPixelY());
|
||||
}
|
||||
if (after.points.size() > 0) {
|
||||
if (before.points.size() == 0) {
|
||||
path.moveTo(tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
tx.add(tb.getCenterPixelX());
|
||||
ty.add(tb.getCenterPixelY());
|
||||
}
|
||||
WptPt pt = after.points.get(0);
|
||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||
path.lineTo(locX, locY);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
}
|
||||
|
|
|
@ -252,8 +252,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
linePath.reset();
|
||||
tx.clear();
|
||||
ty.clear();
|
||||
linePath.moveTo(locX, locY);
|
||||
linePath.lineTo(markerX, markerY);
|
||||
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
tx.add(markerX);
|
||||
|
|
|
@ -140,47 +140,46 @@ public abstract class OsmandMapLayer {
|
|||
|
||||
|
||||
public int calculatePath(RotatedTileBox tb, TIntArrayList xs, TIntArrayList ys, Path path) {
|
||||
boolean start = false;
|
||||
int px = xs.get(0);
|
||||
int py = ys.get(0);
|
||||
int h = tb.getPixHeight();
|
||||
int w = tb.getPixWidth();
|
||||
boolean segmentStarted = false;
|
||||
int prevX = xs.get(0);
|
||||
int prevY = ys.get(0);
|
||||
int height = tb.getPixHeight();
|
||||
int width = tb.getPixWidth();
|
||||
int cnt = 0;
|
||||
boolean pin = isIn(px, py, 0, 0, w, h);
|
||||
boolean prevIn = isIn(prevX, prevY, 0, 0, width, height);
|
||||
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);
|
||||
int currX = xs.get(i);
|
||||
int currY = ys.get(i);
|
||||
boolean currIn = isIn(currX, currY, 0, 0, width, height);
|
||||
boolean draw = false;
|
||||
if (pin && in) {
|
||||
if (prevIn && currIn) {
|
||||
draw = true;
|
||||
} else {
|
||||
long intersection = MapAlgorithms.calculateIntersection(x, y,
|
||||
px, py, 0, w, h, 0);
|
||||
long intersection = MapAlgorithms.calculateIntersection(currX, currY, prevX, prevY, 0, width, height, 0);
|
||||
if (intersection != -1) {
|
||||
if (pin && (i == 1)) {
|
||||
if (prevIn && (i == 1)) {
|
||||
cnt++;
|
||||
path.moveTo(px, py);
|
||||
start = true;
|
||||
path.moveTo(prevX, prevY);
|
||||
segmentStarted = true;
|
||||
}
|
||||
px = (int) (intersection >> 32);
|
||||
py = (int) (intersection & 0xffffffff);
|
||||
prevX = (int) (intersection >> 32);
|
||||
prevY = (int) (intersection & 0xffffffff);
|
||||
draw = true;
|
||||
}
|
||||
}
|
||||
if (draw) {
|
||||
if (!start) {
|
||||
if (!segmentStarted) {
|
||||
cnt++;
|
||||
path.moveTo(px, py);
|
||||
start = true;
|
||||
path.moveTo(prevX, prevY);
|
||||
segmentStarted = true;
|
||||
}
|
||||
path.lineTo(x, y);
|
||||
path.lineTo(currX, currY);
|
||||
} else {
|
||||
start = false;
|
||||
segmentStarted = false;
|
||||
}
|
||||
pin = in;
|
||||
px = x;
|
||||
py = y;
|
||||
prevIn = currIn;
|
||||
prevX = currX;
|
||||
prevY = currY;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
@ -406,7 +405,7 @@ public abstract class OsmandMapLayer {
|
|||
|
||||
|
||||
private void updateDefaultColor(Paint paint, int defaultColor) {
|
||||
if((paint.getColor() == 0 || paint.getColor() == Color.BLACK) && defaultColor != 0) {
|
||||
if ((paint.getColor() == 0 || paint.getColor() == Color.BLACK) && defaultColor != 0) {
|
||||
paint.setColor(defaultColor);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue