diff --git a/docs/Changelog.md b/docs/Changelog.md index a143367d..d3ca44dd 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,6 +2,8 @@ ## New since 0.16.0 +- Drawable style point reduction option [#862](https://github.com/mapsforge/vtm/pull/862) +- Drawable style texture repeat option [#862](https://github.com/mapsforge/vtm/pull/862) - Move cluster experiment in samples [#858](https://github.com/mapsforge/vtm/pull/858) - Many other minor improvements and bug fixes - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.17.0) diff --git a/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java b/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java index 4f074d20..a6c36fd3 100644 --- a/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java +++ b/vtm-jts/src/org/oscim/layers/vector/VectorLayer.java @@ -1,6 +1,6 @@ /* * Copyright 2014 Hannes Janetzek - * Copyright 2016-2019 devemux86 + * Copyright 2016-2021 devemux86 * Copyright 2020 marq24 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). @@ -32,6 +32,7 @@ import org.oscim.layers.vector.geometries.PointDrawable; import org.oscim.layers.vector.geometries.Style; import org.oscim.map.Map; import org.oscim.renderer.bucket.LineBucket; +import org.oscim.renderer.bucket.LineTexBucket; import org.oscim.renderer.bucket.MeshBucket; import org.oscim.theme.styles.AreaStyle; import org.oscim.theme.styles.LineStyle; @@ -235,6 +236,7 @@ public class VectorLayer extends AbstractVectorLayer implements Gestur 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); } for (int i = 0; i < points.getNumGeometries(); i++) { @@ -273,6 +275,9 @@ public class VectorLayer extends AbstractVectorLayer implements Gestur .strokeWidth(style.strokeWidth) .texture(style.texture) .build(); + ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0); + if (ll instanceof LineTexBucket) + ((LineTexBucket) ll).setTexRepeat(style.textureRepeat); } if (!style.fixed && style.strokeIncrease > 1) @@ -304,6 +309,7 @@ public class VectorLayer extends AbstractVectorLayer implements Gestur 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); } 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 e45af117..ae5e5404 100644 --- a/vtm-jts/src/org/oscim/layers/vector/geometries/Style.java +++ b/vtm-jts/src/org/oscim/layers/vector/geometries/Style.java @@ -1,6 +1,6 @@ /* * Copyright 2014 Hannes Janetzek - * Copyright 2016-2019 devemux86 + * Copyright 2016-2021 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -52,6 +52,8 @@ public class Style { public final int stippleColor; public final float stippleWidth; public final TextureItem texture; + public final boolean pointReduction; + public final boolean textureRepeat; public final float heightOffset; public final boolean randomOffset; @@ -76,6 +78,8 @@ public class Style { stippleColor = builder.stippleColor; stippleWidth = builder.stippleWidth; texture = builder.texture; + pointReduction = builder.pointReduction; + textureRepeat = builder.textureRepeat; heightOffset = builder.heightOffset; randomOffset = builder.randomOffset; @@ -111,6 +115,8 @@ public class Style { public int stippleColor = Color.GRAY; public float stippleWidth = 1; public TextureItem texture = null; + public boolean pointReduction = true; + public boolean textureRepeat = true; public float heightOffset = 0; public boolean randomOffset = true; @@ -248,6 +254,16 @@ public class Style { return this; } + public Builder pointReduction(boolean pointReduction) { + this.pointReduction = pointReduction; + return this; + } + + public Builder textureRepeat(boolean textureRepeat) { + this.textureRepeat = textureRepeat; + return this; + } + public Builder heightOffset(float heightOffset) { this.heightOffset = heightOffset; return this; diff --git a/vtm/src/org/oscim/renderer/bucket/LineBucket.java b/vtm/src/org/oscim/renderer/bucket/LineBucket.java index de92e9c6..6b92356f 100644 --- a/vtm/src/org/oscim/renderer/bucket/LineBucket.java +++ b/vtm/src/org/oscim/renderer/bucket/LineBucket.java @@ -1,6 +1,6 @@ /* * Copyright 2013 Hannes Janetzek - * Copyright 2016-2019 devemux86 + * Copyright 2016-2021 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -50,13 +50,13 @@ public class LineBucket extends RenderBucket { /** * maximal resolution */ - private static final float MIN_DIST = 1 / 8f; + public static final float MIN_DIST = 1 / 8f; /** * not quite right.. need to go back so that additional * bevel vertices are at least MIN_DIST apart */ - private static final float BEVEL_MIN = MIN_DIST * 4; + private static final float MIN_BEVEL = MIN_DIST * 4; /** * mask for packing last two bits of extrusion vector with texture @@ -71,6 +71,7 @@ public class LineBucket extends RenderBucket { public boolean roundCap; private float mMinDist = MIN_DIST; + private float mMinBevel = MIN_BEVEL; public float heightOffset; @@ -103,7 +104,14 @@ public class LineBucket extends RenderBucket { * For point reduction by minimal distance. Default is 1/8. */ public void setDropDistance(float minDist) { - mMinDist = Math.max(minDist, MIN_DIST); + mMinDist = minDist; + } + + /** + * Default is MIN_DIST * 4 = 1/8 * 4. + */ + public void setBevelDistance(float minBevel) { + mMinBevel = minBevel; } public void addLine(GeometryBuffer geom) { @@ -395,18 +403,18 @@ public class LineBucket extends RenderBucket { uy /= a; } //log.debug("aside " + a + " " + ux + " " + uy); - px = curX - ux * BEVEL_MIN; - py = curY - uy * BEVEL_MIN; - curX = curX + ux * BEVEL_MIN; - curY = curY + uy * BEVEL_MIN; + px = curX - ux * mMinBevel; + py = curY - uy * mMinBevel; + curX = curX + ux * mMinBevel; + curY = curY + uy * mMinBevel; } else { //log.debug("back"); /* go back by min dist */ - px = curX + vPrevX * BEVEL_MIN; - py = curY + vPrevY * BEVEL_MIN; + px = curX + vPrevX * mMinBevel; + py = curY + vPrevY * mMinBevel; /* go forward by min dist */ - curX = curX + vNextX * BEVEL_MIN; - curY = curY + vNextY * BEVEL_MIN; + curX = curX + vNextX * mMinBevel; + curY = curY + vNextY * mMinBevel; } /* unit vector pointing forward to next node */ diff --git a/vtm/src/org/oscim/renderer/bucket/LineTexBucket.java b/vtm/src/org/oscim/renderer/bucket/LineTexBucket.java index 713fe29f..44252214 100644 --- a/vtm/src/org/oscim/renderer/bucket/LineTexBucket.java +++ b/vtm/src/org/oscim/renderer/bucket/LineTexBucket.java @@ -1,6 +1,6 @@ /* * Copyright 2013 Hannes Janetzek - * Copyright 2016-2018 devemux86 + * Copyright 2016-2021 devemux86 * Copyright 2017 Longri * Copyright 2018 Gustl22 * @@ -21,11 +21,7 @@ package org.oscim.renderer.bucket; import org.oscim.backend.GL; import org.oscim.core.GeometryBuffer; -import org.oscim.renderer.GLShader; -import org.oscim.renderer.GLState; -import org.oscim.renderer.GLUtils; -import org.oscim.renderer.GLViewport; -import org.oscim.renderer.MapRenderer; +import org.oscim.renderer.*; import org.oscim.theme.styles.LineStyle; import org.oscim.utils.FastMath; import org.slf4j.Logger; @@ -36,9 +32,7 @@ import java.nio.ByteOrder; import java.nio.ShortBuffer; import static org.oscim.backend.GLAdapter.gl; -import static org.oscim.renderer.MapRenderer.COORD_SCALE; -import static org.oscim.renderer.MapRenderer.MAX_INDICES; -import static org.oscim.renderer.MapRenderer.bindQuadIndicesVBO; +import static org.oscim.renderer.MapRenderer.*; /** * RenderElement for textured or stippled lines @@ -93,6 +87,7 @@ public final class LineTexBucket extends LineBucket { public int oddQuads; private boolean evenSegment = true; + private boolean mTexRepeat = true; LineTexBucket(int level) { super(TEXLINE, false, true); @@ -101,6 +96,10 @@ public final class LineTexBucket extends LineBucket { this.evenSegment = true; } + public void setTexRepeat(boolean texRepeat) { + mTexRepeat = texRepeat; + } + @Override public void addLine(GeometryBuffer geom) { addLine(geom.points, geom.index, -1, false); @@ -185,7 +184,8 @@ public final class LineTexBucket extends LineBucket { } else { addShortVertex(vi, (short) x, (short) y, (short) nx, (short) ny, dx, dy, (short) lineLength, (int) dist); - lineLength += dist; + if (mTexRepeat) + lineLength += dist; } x = nx; y = ny;