diff --git a/vtm-android-example/src/org/oscim/android/test/VectorLayerActivity.java b/vtm-android-example/src/org/oscim/android/test/VectorLayerActivity.java index bfe7d9284..b1f717aec 100644 --- a/vtm-android-example/src/org/oscim/android/test/VectorLayerActivity.java +++ b/vtm-android-example/src/org/oscim/android/test/VectorLayerActivity.java @@ -18,13 +18,18 @@ package org.oscim.android.test; import android.os.Bundle; - import org.oscim.backend.canvas.Color; +import org.oscim.backend.canvas.Paint; +import org.oscim.core.GeoPoint; import org.oscim.layers.vector.VectorLayer; +import org.oscim.layers.vector.geometries.LineDrawable; import org.oscim.layers.vector.geometries.PointDrawable; import org.oscim.layers.vector.geometries.Style; import org.oscim.utils.ColorUtil; +import java.util.Arrays; +import java.util.List; + public class VectorLayerActivity extends BitmapTileActivity { @Override @@ -67,6 +72,15 @@ public void onCreate(Bundle savedInstanceState) { // } // } + addRandomCircles(vectorLayer); + addThickSemitransparentPolyline(vectorLayer); + + vectorLayer.update(); + + mMap.layers().add(vectorLayer); + } + + private void addRandomCircles(VectorLayer vectorLayer) { Style.Builder sb = Style.builder() .buffer(0.5) .fillColor(Color.RED) @@ -84,9 +98,26 @@ public void onCreate(Bundle savedInstanceState) { style)); } - vectorLayer.update(); + } - mMap.layers().add(vectorLayer); + private void addThickSemitransparentPolyline(VectorLayer vectorLayer) { + final Style style = Style.builder() + .strokeWidth(20f) + .strokeColor(Color.setA(Color.BLUE, 127)) + .cap(Paint.Cap.BUTT) + .dropDistance(10f) + .fixed(true) + .build(); + + //create a polyline in Hamburg, Germany + final List points = Arrays.asList( + new GeoPoint(53.5334, 10.069833), new GeoPoint(53.5419, 10.09075), new GeoPoint(53.53745, 10.091017), new GeoPoint(53.54105, 10.0928), new GeoPoint(53.536721, 10.09416), + new GeoPoint(53.5406, 10.08365), new GeoPoint(53.5406, 11.0) + ); + + final LineDrawable line = new LineDrawable(points, style); + + vectorLayer.add(line); } @Override diff --git a/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java b/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java index 2b1de9665..1f6841286 100644 --- a/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java +++ b/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java @@ -257,7 +257,7 @@ protected void drawPoint(Task t, int level, Geometry points, Style style) { LineBucket ll = t.buckets.getLineBucket(level + 1); if (ll.line == null) { ll.line = new LineStyle(2, style.strokeColor, style.strokeWidth); - ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0); + ll.setDropDistance(style.dropDistance); } for (int i = 0; i < points.getNumGeometries(); i++) { @@ -296,7 +296,7 @@ protected void drawLine(Task t, int level, Geometry line, Style style) { .strokeWidth(style.strokeWidth) .texture(style.texture) .build(); - ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0); + ll.setDropDistance(style.dropDistance); if (ll instanceof LineTexBucket) ((LineTexBucket) ll).setTexRepeat(style.textureRepeat); } @@ -330,7 +330,7 @@ protected void drawPolygon(Task t, int level, Geometry polygon, Style style) { LineBucket ll = t.buckets.getLineBucket(level + 1); if (ll.line == null) { ll.line = new LineStyle(2, style.strokeColor, style.strokeWidth); - ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0); + ll.setDropDistance(style.dropDistance); } if (style.generalization != Style.GENERALIZATION_NONE) { diff --git a/vtm-jts/src/org/oscim/layers/vector/geometries/Style.java b/vtm-jts/src/org/oscim/layers/vector/geometries/Style.java index ae5e5404d..5e7e8bcce 100644 --- a/vtm-jts/src/org/oscim/layers/vector/geometries/Style.java +++ b/vtm-jts/src/org/oscim/layers/vector/geometries/Style.java @@ -19,6 +19,7 @@ import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Paint; +import org.oscim.renderer.bucket.LineBucket; import org.oscim.renderer.bucket.TextureItem; import static org.oscim.backend.canvas.Color.parseColor; @@ -52,7 +53,7 @@ public class Style { public final int stippleColor; public final float stippleWidth; public final TextureItem texture; - public final boolean pointReduction; + public final float dropDistance; public final boolean textureRepeat; public final float heightOffset; @@ -78,7 +79,7 @@ private Style(Builder builder) { stippleColor = builder.stippleColor; stippleWidth = builder.stippleWidth; texture = builder.texture; - pointReduction = builder.pointReduction; + dropDistance = builder.dropDistance; textureRepeat = builder.textureRepeat; heightOffset = builder.heightOffset; @@ -115,7 +116,7 @@ public static class Builder { public int stippleColor = Color.GRAY; public float stippleWidth = 1; public TextureItem texture = null; - public boolean pointReduction = true; + public float dropDistance = LineBucket.MIN_DIST; public boolean textureRepeat = true; public float heightOffset = 0; @@ -254,8 +255,8 @@ public Builder texture(TextureItem texture) { return this; } - public Builder pointReduction(boolean pointReduction) { - this.pointReduction = pointReduction; + public Builder dropDistance(float dropDistance) { + this.dropDistance = dropDistance; return this; }