add LineLayer setExtents to not add caps outside visible region

This commit is contained in:
Hannes Janetzek 2014-06-10 20:20:56 +02:00
parent bf8cc329cf
commit 9d078142aa
2 changed files with 9 additions and 5 deletions

View File

@ -23,6 +23,7 @@ import org.oscim.core.MapElement;
import org.oscim.core.MercatorProjection; import org.oscim.core.MercatorProjection;
import org.oscim.core.Tag; import org.oscim.core.Tag;
import org.oscim.core.TagSet; import org.oscim.core.TagSet;
import org.oscim.core.Tile;
import org.oscim.layers.tile.MapTile; import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileLoader; import org.oscim.layers.tile.TileLoader;
import org.oscim.layers.tile.vector.VectorTileLayer.TileLoaderProcessHook; import org.oscim.layers.tile.vector.VectorTileLayer.TileLoaderProcessHook;
@ -245,6 +246,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
if (ll.line == null) { if (ll.line == null) {
ll.line = line; ll.line = line;
ll.scale = line.fixed ? 1 : mLineScale; ll.scale = line.fixed ? 1 : mLineScale;
ll.setExtents(-4, Tile.SIZE + 4);
} }
if (line.outline) { if (line.outline) {

View File

@ -24,7 +24,6 @@ import org.oscim.backend.GLAdapter;
import org.oscim.backend.canvas.Paint.Cap; import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer; import org.oscim.core.GeometryBuffer;
import org.oscim.core.MercatorProjection; import org.oscim.core.MercatorProjection;
import org.oscim.core.Tile;
import org.oscim.renderer.GLShader; import org.oscim.renderer.GLShader;
import org.oscim.renderer.GLState; import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils; import org.oscim.renderer.GLUtils;
@ -73,6 +72,8 @@ public final class LineLayer extends RenderElement {
public float heightOffset; public float heightOffset;
private int tmin = Integer.MIN_VALUE, tmax = Integer.MAX_VALUE;
LineLayer(int layer) { LineLayer(int layer) {
super(RenderElement.LINE); super(RenderElement.LINE);
this.level = layer; this.level = layer;
@ -87,6 +88,11 @@ public final class LineLayer extends RenderElement {
outlines = link; outlines = link;
} }
public void setExtents(int min, int max) {
tmin = min;
tmax = max;
}
/** /**
* For point reduction by minimal distance. Default is 1/8. * For point reduction by minimal distance. Default is 1/8.
*/ */
@ -108,9 +114,6 @@ public final class LineLayer extends RenderElement {
addLine(points, null, numPoints, closed); addLine(points, null, numPoints, closed);
} }
private static int tmax = Tile.SIZE + 4;
private static int tmin = -4;
private void addLine(float[] points, short[] index, int numPoints, boolean closed) { private void addLine(float[] points, short[] index, int numPoints, boolean closed) {
boolean rounded = false; boolean rounded = false;
@ -272,7 +275,6 @@ public final class LineLayer extends RenderElement {
curX = points[ipos++]; curX = points[ipos++];
curY = points[ipos++]; curY = points[ipos++];
nextX = points[ipos++]; nextX = points[ipos++];
nextY = points[ipos++]; nextY = points[ipos++];