Merge pull request #743 from mapsforge/symbol

Render themes - symbols on lines: add billboard, rotate options
This commit is contained in:
Emux
2019-09-28 19:45:05 +03:00
committed by GitHub
14 changed files with 64 additions and 26 deletions

View File

@@ -2,6 +2,7 @@
## New since 0.12.0
- Render themes: symbols on lines with billboard, rotate [#743](https://github.com/mapsforge/vtm/pull/743)
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.13.0)

View File

@@ -237,9 +237,11 @@
<xs:attribute name="symbol-width" type="xs:positiveInteger" use="optional" />
<xs:attribute name="symbol-height" type="xs:positiveInteger" use="optional" />
<xs:attribute name="symbol-percent" type="xs:positiveInteger" use="optional" />
<xs:attribute name="billboard" default="false" type="xs:boolean" use="optional" />
<xs:attribute name="repeat" default="false" type="xs:boolean" use="optional" />
<xs:attribute name="repeat-gap" default="200" type="xs:float" use="optional" />
<xs:attribute name="repeat-start" default="30" type="xs:float" use="optional" />
<xs:attribute name="rotate" default="true" type="xs:boolean" use="optional" />
</xs:complexType>
<xs:complexType name="extrusion">

View File

@@ -1078,7 +1078,7 @@
<m k="area" v="~|false|no">
<m k="highway">
<m k="oneway" v="yes|true" zoom-min="16">
<lineSymbol src="assets:symbols/oneway.svg" />
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>

View File

@@ -1038,7 +1038,7 @@
<m k="area" v="~|false|no">
<m k="kind_detail">
<m k="oneway" v="yes|true" zoom-min="16">
<lineSymbol src="assets:symbols/oneway.svg" />
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>

View File

@@ -1080,7 +1080,7 @@
<m k="area" v="~|false|no">
<m k="highway">
<m k="oneway" v="yes|true" zoom-min="16">
<lineSymbol src="assets:symbols/oneway.svg" />
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>

View File

@@ -328,7 +328,12 @@
<line outline="motorway" use="highway:z11" />
</m>
</m>
<!--</m>-->
<m k="oneway" v="1" zoom-min="16">
<m k="class" v="motorway|trunk|primary|secondary|tertiary|minor">
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>
<m k="layer" v="transportation_name">

View File

@@ -982,7 +982,7 @@
<m k="area" v="~|false|no">
<m k="highway">
<m k="oneway" v="yes|true" zoom-min="16">
<lineSymbol src="assets:symbols/oneway.svg" />
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>

View File

@@ -982,7 +982,7 @@
<m k="area" v="~|false|no">
<m k="highway">
<m k="oneway" v="yes|true" zoom-min="16">
<lineSymbol src="assets:symbols/oneway.svg" />
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>

View File

@@ -1073,7 +1073,7 @@
<m k="area" v="~|false|no">
<m k="highway">
<m k="oneway" v="yes|true" zoom-min="16">
<lineSymbol src="assets:symbols/oneway.svg" />
<symbol repeat="true" src="assets:symbols/oneway.svg" />
</m>
</m>
</m>

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86
* Copyright 2016-2019 devemux86
* Copyright 2018 Gustl22
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -522,7 +522,8 @@ public class LabelPlacement {
s.texRegion = ti.texRegion;
s.x = x;
s.y = y;
s.billboard = true;
s.billboard = ti.billboard;
s.rotation = ti.rotation;
sl.addSymbol(s);
}
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013 Hannes Janetzek
* Copyright 2018 devemux86
* Copyright 2018-2019 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -63,20 +63,19 @@ public final class WayDecorator {
previousX += diffX * segmentSkipPercentage;
previousY += diffY * segmentSkipPercentage;
// TODO
/*if (rotate) {
if (symbol.rotate) {
// if we do not rotate theta will be 0, which is correct
theta = (float) Math.atan2(currentY - previousY, currentX - previousX);
}*/
theta = (float) Math.toDegrees(Math.atan2(currentY - previousY, currentX - previousX));
}
float x = previousX;
float y = previousY;
if (x >= 0 && x <= Tile.SIZE && y >= 0 && y <= Tile.SIZE) {
SymbolItem s = SymbolItem.pool.get();
if (symbol.bitmap != null)
s.set(x, y, symbol.bitmap, 0, true);
s.set(x, y, symbol.bitmap, theta, symbol.billboard);
else
s.set(x, y, symbol.texture, 0, true);
s.set(x, y, symbol.texture, theta, symbol.billboard);
ld.symbols.push(s);
}

View File

@@ -1163,6 +1163,9 @@ public class XmlThemeBuilder extends DefaultHandler {
else if ("symbol-scaling".equals(name))
; // no-op
else if ("billboard".equals(name))
b.billboard(Boolean.parseBoolean(value));
else if ("repeat".equals(name))
b.repeat(Boolean.parseBoolean(value));
@@ -1172,6 +1175,9 @@ public class XmlThemeBuilder extends DefaultHandler {
else if ("repeat-gap".equals(name))
b.repeatGap = Float.parseFloat(value) * mScale;
else if ("rotate".equals(name))
b.rotate(Boolean.parseBoolean(value));
else
logUnknownAttribute(elementName, name, value, i);
}

View File

@@ -19,6 +19,7 @@
*/
package org.oscim.theme.styles;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.renderer.bucket.TextureItem;
@@ -58,15 +59,15 @@ public final class LineStyle extends RenderStyle<LineStyle> {
public final float repeatGap;
public LineStyle(int stroke, float width) {
this(0, "", stroke, width, Cap.BUTT, true, 1, 0, 0, 0, -1, 0, false, null, true, null, REPEAT_START_DEFAULT, REPEAT_GAP_DEFAULT);
this(0, "", stroke, width, Cap.BUTT, true, 1, 0, 0, 0, -1, 0, false, null, true, null, REPEAT_START_DEFAULT * CanvasAdapter.getScale(), REPEAT_GAP_DEFAULT * CanvasAdapter.getScale());
}
public LineStyle(int level, int stroke, float width) {
this(level, "", stroke, width, Cap.BUTT, true, 1, 0, 0, 0, -1, 0, false, null, true, null, REPEAT_START_DEFAULT, REPEAT_GAP_DEFAULT);
this(level, "", stroke, width, Cap.BUTT, true, 1, 0, 0, 0, -1, 0, false, null, true, null, REPEAT_START_DEFAULT * CanvasAdapter.getScale(), REPEAT_GAP_DEFAULT * CanvasAdapter.getScale());
}
public LineStyle(int stroke, float width, Cap cap) {
this(0, "", stroke, width, cap, true, 1, 0, 0, 0, -1, 0, false, null, true, null, REPEAT_START_DEFAULT, REPEAT_GAP_DEFAULT);
this(0, "", stroke, width, cap, true, 1, 0, 0, 0, -1, 0, false, null, true, null, REPEAT_START_DEFAULT * CanvasAdapter.getScale(), REPEAT_GAP_DEFAULT * CanvasAdapter.getScale());
}
public LineStyle(int level, String style, int color, float width,
@@ -328,8 +329,8 @@ public final class LineStyle extends RenderStyle<LineStyle> {
symbolPercent = 100;
dashArray = null;
repeatStart = REPEAT_START_DEFAULT;
repeatGap = REPEAT_GAP_DEFAULT;
repeatStart = REPEAT_START_DEFAULT * CanvasAdapter.getScale();
repeatGap = REPEAT_GAP_DEFAULT * CanvasAdapter.getScale();
return self();
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013 Hannes Janetzek
* Copyright 2016-2018 devemux86
* Copyright 2016-2019 devemux86
* Copyright 2017 Longri
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -19,6 +19,7 @@
*/
package org.oscim.theme.styles;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.atlas.TextureRegion;
@@ -38,9 +39,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
public final int symbolHeight;
public final int symbolPercent;
public final boolean billboard;
public final boolean repeat;
public final float repeatStart;
public final float repeatGap;
public final boolean rotate;
public SymbolStyle(Bitmap bitmap) {
this(bitmap, null, 0);
@@ -63,9 +66,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
this.symbolHeight = 0;
this.symbolPercent = 100;
this.billboard = false;
this.repeat = false;
this.repeatStart = REPEAT_START_DEFAULT;
this.repeatGap = REPEAT_GAP_DEFAULT;
this.repeatStart = REPEAT_START_DEFAULT * CanvasAdapter.getScale();
this.repeatGap = REPEAT_GAP_DEFAULT * CanvasAdapter.getScale();
this.rotate = true;
}
public SymbolStyle(SymbolBuilder<?> b) {
@@ -79,9 +84,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
this.symbolHeight = b.symbolHeight;
this.symbolPercent = b.symbolPercent;
this.billboard = b.billboard;
this.repeat = b.repeat;
this.repeatStart = b.repeatStart;
this.repeatGap = b.repeatGap;
this.rotate = b.rotate;
}
@Override
@@ -115,9 +122,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
public int symbolHeight;
public int symbolPercent;
public boolean billboard;
public boolean repeat;
public float repeatStart;
public float repeatGap;
public boolean rotate;
public SymbolBuilder() {
}
@@ -136,9 +145,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
this.symbolHeight = symbol.symbolHeight;
this.symbolPercent = symbol.symbolPercent;
this.billboard = symbol.billboard;
this.repeat = symbol.repeat;
this.repeatStart = symbol.repeatStart;
this.repeatGap = symbol.repeatGap;
this.rotate = symbol.rotate;
return self();
}
@@ -173,6 +184,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
return self();
}
public T billboard(boolean billboard) {
this.billboard = billboard;
return self();
}
public T repeat(boolean repeat) {
this.repeat = repeat;
return self();
@@ -188,6 +204,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
return self();
}
public T rotate(boolean rotate) {
this.rotate = rotate;
return self();
}
public T reset() {
cat = null;
@@ -199,9 +220,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
symbolHeight = 0;
symbolPercent = 100;
billboard = false;
repeat = false;
repeatStart = REPEAT_START_DEFAULT;
repeatGap = REPEAT_GAP_DEFAULT;
repeatStart = REPEAT_START_DEFAULT * CanvasAdapter.getScale();
repeatGap = REPEAT_GAP_DEFAULT * CanvasAdapter.getScale();
rotate = true;
return self();
}