Prevented current track from participating in line reduction

The current track is constantly changing. It is not suitable for the line culling stuff, so that track is detected
and special-cased.
This commit is contained in:
Andrew Davie 2016-04-01 01:18:20 +11:00
parent 7e9afc68d6
commit 7ee1cae93c
2 changed files with 24 additions and 24 deletions

View file

@ -330,17 +330,18 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD) if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD)
&& !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how? && !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how?
boolean showCT = g.isShowCurrentTrack(); if (g.isShowCurrentTrack()) {
Renderable.StandardTrack st = new Renderable.StandardTrack(ts.points, 18);
ts.renders.add(new Renderable.Altitude(ts.points, 10)); st.setCurrentTrack();
ts.renders.add(new Renderable.StandardTrack(ts.points, 18)); ts.renders.add(st);
} else {
// TODO : enable these to see how the experimental conveyor, altitude, speed, waypoint renders work ts.renders.add(new Renderable.Altitude(ts.points, 10));
ts.renders.add(new Renderable.StandardTrack(ts.points, 18));
//ts.renders.add(new Renderable.Conveyor(ts.points, view, 20, 250)); //ts.renders.add(new Renderable.Conveyor(ts.points, view, 20, 250));
ts.renders.add(new Renderable.DistanceMarker(ts.points, view, 1000)); ts.renders.add(new Renderable.DistanceMarker(ts.points, view, 1000));
//ts.renders.add(new Renderable.Speed(ts.points, 50, 128)); //ts.renders.add(new Renderable.Speed(ts.points, 50, 128));
ts.renders.add(new Renderable.Arrows(ts.points,view,10,250)); ts.renders.add(new Renderable.Arrows(ts.points, view, 10, 250));
}
} }
ts.recalculateRenderScales(view.getZoom()); ts.recalculateRenderScales(view.getZoom());

View file

@ -60,7 +60,7 @@ public class Renderable {
Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY); Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY);
double zoom; double zoom = -1;
double hashPoint; double hashPoint;
boolean shadow = false; // TODO: fixup shadow support boolean shadow = false; // TODO: fixup shadow support
@ -115,25 +115,24 @@ public class Renderable {
public static class StandardTrack extends RenderableSegment { public static class StandardTrack extends RenderableSegment {
double base; // parameter for calculating Ramer-Douglas-Peucer distance double base; // parameter for calculating Ramer-Douglas-Peucer distance
boolean currentTrack = false;
public StandardTrack(List<GPXUtilities.WptPt> pt, double base) { public StandardTrack(List<GPXUtilities.WptPt> pt, double base) {
super(pt); super(pt);
this.base = base; this.base = base;
} }
public void setCurrentTrack() {
currentTrack = true;
}
@Override public void recalculateRenderScale(double zoom) { @Override public void recalculateRenderScale(double zoom) {
// Here we create the 'shadow' resampled/culled points list, based on the asynchronous call. // Here we create the 'shadow' resampled/culled points list, based on the asynchronous call.
// The asynchronous callback will set the variable, and that is preferentially used for rendering // The asynchronous callback will set the variable 'culled', and that is preferentially used for rendering
// The current track does not undergo this process, as it is potentially constantly changing.
double hashCode = points.hashCode() ; if (!currentTrack && this.zoom != zoom) {
if (hashPoint != hashCode) { // current track, changing?
if (culler != null) {
culler.cancel(true); // STOP culling a track with changing points
culled = null; // and force use of original track
}
} else if (culler == null || this.zoom != zoom) {
if (culler != null) { if (culler != null) {
culler.cancel(true); culler.cancel(true);
@ -143,7 +142,7 @@ public class Renderable {
culler = new AsynchronousResampler.RamerDouglasPeucer(this, cullDistance); culler = new AsynchronousResampler.RamerDouglasPeucer(this, cullDistance);
if (this.zoom < zoom) { // if line would look worse (we're zooming in) then... if (this.zoom < zoom) { // if line would look worse (we're zooming in) then...
culled = null; // use full-resolution until re-cull complete culled = null; // use full-resolution until re-cull complete
} }
this.zoom = zoom; this.zoom = zoom;
@ -479,7 +478,7 @@ public class Renderable {
float sizer = (float) Math.pow(2.0,zoom-18) * 128; float sizer = (float) Math.pow(2.0,zoom-18) * 128;
int pCol = p.getColor(); int pCol = p.getColor();
p.setColor(getComplementaryColor(p.getColor())); // and a complementary colour p.setColor(Color.RED); //getComplementaryColor(p.getColor())); // and a complementary colour
float lastx = Float.NEGATIVE_INFINITY; float lastx = Float.NEGATIVE_INFINITY;
float lasty = Float.NEGATIVE_INFINITY; float lasty = Float.NEGATIVE_INFINITY;
@ -509,7 +508,7 @@ public class Renderable {
&& Math.min(y, lasty) < clipT && Math.max(y, lasty) > clipB) { && Math.min(y, lasty) < clipT && Math.max(y, lasty) > clipB) {
if ((intp & 15) < 6) { if ((intp & 15) < 6) {
p.setStrokeWidth(stroke * (1f + 1.25f* (5 - (intp & 7)) / 2f)); p.setStrokeWidth(stroke * (0.75f + 1.f* (5 - (intp & 7)) / 2f));
if (!broken) { if (!broken) {
canvas.drawLine(lastx, lasty, x, y, p); canvas.drawLine(lastx, lasty, x, y, p);