Fix qt builds with routes
This commit is contained in:
parent
ec42479638
commit
d6d63e1cb2
3 changed files with 66 additions and 15 deletions
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -304,7 +306,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
WptPt ls = l.get(i);
|
WptPt ls = l.get(i);
|
||||||
if (startIndex == -1) {
|
if (startIndex == -1) {
|
||||||
if (ls.lat >= latLonBounds.bottom - 0.1 && ls.lat <= latLonBounds.top + 0.1 && ls.lon >= latLonBounds.left - 0.1
|
if (ls.lat >= latLonBounds.bottom - 0.1 && ls.lat <= latLonBounds.top + 0.1 && ls.lon >= latLonBounds.left - 0.1
|
||||||
&& ls.lon <= latLonBounds.right + 0.1 && !isPointVisited(ls)) {
|
&& ls.lon <= latLonBounds.right + 0.1) {
|
||||||
startIndex = i > 0 ? i - 1 : i;
|
startIndex = i > 0 ? i - 1 : i;
|
||||||
}
|
}
|
||||||
} else if (!(latLonBounds.left <= ls.lon + 0.1 && ls.lon - 0.1 <= latLonBounds.right
|
} else if (!(latLonBounds.left <= ls.lon + 0.1 && ls.lon - 0.1 <= latLonBounds.right
|
||||||
|
@ -326,18 +328,16 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
|
|
||||||
|
|
||||||
private void drawSegment(Canvas canvas, RotatedTileBox tb, List<WptPt> l, int startIndex, int endIndex) {
|
private void drawSegment(Canvas canvas, RotatedTileBox tb, List<WptPt> l, int startIndex, int endIndex) {
|
||||||
int px = tb.getPixXFromLonNoRot(l.get(startIndex).lon);
|
TIntArrayList tx = new TIntArrayList();
|
||||||
int py = tb.getPixYFromLatNoRot(l.get(startIndex).lat);
|
TIntArrayList ty = new TIntArrayList();
|
||||||
path.moveTo(px, py);
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
for (int i = startIndex + 1; i <= endIndex; i++) {
|
|
||||||
WptPt p = l.get(i);
|
WptPt p = l.get(i);
|
||||||
if(isPointVisited(p)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int x = tb.getPixXFromLonNoRot(p.lon);
|
int x = tb.getPixXFromLonNoRot(p.lon);
|
||||||
int y = tb.getPixYFromLatNoRot(p.lat);
|
int y = tb.getPixYFromLatNoRot(p.lat);
|
||||||
path.lineTo(x, y);
|
tx.add(x);
|
||||||
|
ty.add(y);
|
||||||
}
|
}
|
||||||
|
calculatePath(tb, tx, ty, path);
|
||||||
if(isPaint_1) {
|
if(isPaint_1) {
|
||||||
canvas.drawPath(path, paint_1);
|
canvas.drawPath(path, paint_1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
import net.osmand.util.MapAlgorithms;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Path;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
@ -69,6 +73,49 @@ public abstract class OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean isIn(int x, int y, int lx, int ty, int rx, int by) {
|
||||||
|
return x >= lx && x <= rx && y >= ty && y <= by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 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 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);
|
||||||
|
if(pin && in) {
|
||||||
|
if(!start) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pin = in;
|
||||||
|
px = x;
|
||||||
|
py = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract class MapLayerData<T> {
|
public abstract class MapLayerData<T> {
|
||||||
public int ZOOM_THRESHOLD = 1;
|
public int ZOOM_THRESHOLD = 1;
|
||||||
public RotatedTileBox queriedBox;
|
public RotatedTileBox queriedBox;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -8,6 +10,7 @@ import net.osmand.Location;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.render.OsmandRenderer;
|
import net.osmand.plus.render.OsmandRenderer;
|
||||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
@ -161,16 +164,17 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
private void drawSegment(RotatedTileBox tb, Canvas canvas) {
|
private void drawSegment(RotatedTileBox tb, Canvas canvas) {
|
||||||
if (points.size() > 0) {
|
if (points.size() > 0) {
|
||||||
paint.setStrokeWidth(12 * tb.getDensity());
|
paint.setStrokeWidth(12 * tb.getDensity());
|
||||||
|
TIntArrayList tx = new TIntArrayList();
|
||||||
int px = tb.getPixXFromLonNoRot(points.get(0).getLongitude());
|
TIntArrayList ty = new TIntArrayList();
|
||||||
int py = tb.getPixYFromLatNoRot(points.get(0).getLatitude());
|
for (int i = 0; i < points.size(); i++) {
|
||||||
path.moveTo(px, py);
|
|
||||||
for (int i = 1; i < points.size(); i++) {
|
|
||||||
Location o = points.get(i);
|
Location o = points.get(i);
|
||||||
int x = tb.getPixXFromLonNoRot(o.getLongitude());
|
int x = tb.getPixXFromLonNoRot(o.getLongitude());
|
||||||
int y = tb.getPixYFromLatNoRot(o.getLatitude());
|
int y = tb.getPixYFromLatNoRot(o.getLatitude());
|
||||||
path.lineTo(x, y);
|
tx.add(x);
|
||||||
|
ty.add(y);
|
||||||
}
|
}
|
||||||
|
calculatePath(tb, tx, ty, path);
|
||||||
|
|
||||||
if(isPaint_1) {
|
if(isPaint_1) {
|
||||||
canvas.drawPath(path, paint_1);
|
canvas.drawPath(path, paint_1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue