Fix gpx layer
This commit is contained in:
parent
ea3845fe70
commit
2bb7f051a2
1 changed files with 16 additions and 13 deletions
|
@ -52,7 +52,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
private int cachedHash;
|
private int cachedHash;
|
||||||
private int cachedColor;
|
private int cachedColor;
|
||||||
|
|
||||||
private Path path;
|
|
||||||
private static final int startZoom = 7;
|
private static final int startZoom = 7;
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +91,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
paint_1.setAntiAlias(true);
|
paint_1.setAntiAlias(true);
|
||||||
|
|
||||||
|
|
||||||
path = new Path();
|
|
||||||
|
|
||||||
paintBmp = new Paint();
|
paintBmp = new Paint();
|
||||||
paintBmp.setAntiAlias(true);
|
paintBmp.setAntiAlias(true);
|
||||||
|
@ -302,35 +300,40 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
private void drawSegments(Canvas canvas, RotatedTileBox tileBox, List<TrkSegment> points) {
|
private void drawSegments(Canvas canvas, RotatedTileBox tileBox, List<TrkSegment> points) {
|
||||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||||
for (TrkSegment l : points) {
|
for (TrkSegment l : points) {
|
||||||
path.rewind();
|
|
||||||
int startIndex = -1;
|
int startIndex = -1;
|
||||||
int endIndex = -1;
|
int endIndex = -1;
|
||||||
int prevCross = 0;
|
int prevCross = 0;
|
||||||
boolean intersect = false;
|
double shift = 0.1;
|
||||||
|
|
||||||
for (int i = 0; i < l.points.size(); i++) {
|
for (int i = 0; i < l.points.size(); i++) {
|
||||||
WptPt ls = l.points.get(i);
|
WptPt ls = l.points.get(i);
|
||||||
int cross = 0;
|
int cross = 0;
|
||||||
cross |= (ls.lon < latLonBounds.left - 0.1 ? 1 : 0);
|
cross |= (ls.lon < latLonBounds.left - shift ? 1 : 0);
|
||||||
cross |= (ls.lon > latLonBounds.right + 0.1 ? 2 : 0);
|
cross |= (ls.lon > latLonBounds.right + shift ? 2 : 0);
|
||||||
cross |= (ls.lat > latLonBounds.top + 0.1 ? 4 : 0);
|
cross |= (ls.lat > latLonBounds.top + shift ? 4 : 0);
|
||||||
cross |= (ls.lat < latLonBounds.bottom - 0.1 ? 8 : 0);
|
cross |= (ls.lat < latLonBounds.bottom - shift ? 8 : 0);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
if ((prevCross & cross) == 0) {
|
if ((prevCross & cross) == 0) {
|
||||||
if (prevCross != 0 || !intersect) {
|
if(prevCross == 0 && endIndex != -1) {
|
||||||
|
// continue previous line
|
||||||
|
} else {
|
||||||
|
// start new segment
|
||||||
if (startIndex > 0) {
|
if (startIndex > 0) {
|
||||||
drawSegment(canvas, tileBox, l, startIndex, endIndex);
|
drawSegment(canvas, tileBox, l, startIndex, endIndex);
|
||||||
}
|
}
|
||||||
startIndex = i - 1;
|
startIndex = i - 1;
|
||||||
}
|
}
|
||||||
endIndex = i;
|
endIndex = i;
|
||||||
intersect = true;
|
} else {
|
||||||
|
if (startIndex != -1) {
|
||||||
|
drawSegment(canvas, tileBox, l, startIndex, endIndex);
|
||||||
|
startIndex = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevCross = cross;
|
prevCross = cross;
|
||||||
}
|
}
|
||||||
if (startIndex != -1) {
|
if (startIndex != -1) {
|
||||||
drawSegment(canvas, tileBox, l, startIndex, l.points.size() - 1);
|
drawSegment(canvas, tileBox, l, startIndex, endIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +348,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
TIntArrayList tx = new TIntArrayList();
|
TIntArrayList tx = new TIntArrayList();
|
||||||
TIntArrayList ty = new TIntArrayList();
|
TIntArrayList ty = new TIntArrayList();
|
||||||
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||||
|
Path path = new Path();
|
||||||
for (int i = startIndex; i <= endIndex; i++) {
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
WptPt p = l.points.get(i);
|
WptPt p = l.points.get(i);
|
||||||
int x = (int) tb.getPixXFromLatLon(p.lat, p.lon);
|
int x = (int) tb.getPixXFromLatLon(p.lat, p.lon);
|
||||||
|
|
Loading…
Reference in a new issue