Merge pull request #743 from mapsforge/symbol
Render themes - symbols on lines: add billboard, rotate options
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## New since 0.12.0
|
## 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
|
- Many other minor improvements and bug fixes
|
||||||
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.13.0)
|
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.13.0)
|
||||||
|
|
||||||
|
|||||||
@@ -237,9 +237,11 @@
|
|||||||
<xs:attribute name="symbol-width" type="xs:positiveInteger" use="optional" />
|
<xs:attribute name="symbol-width" type="xs:positiveInteger" use="optional" />
|
||||||
<xs:attribute name="symbol-height" 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="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" default="false" type="xs:boolean" use="optional" />
|
||||||
<xs:attribute name="repeat-gap" default="200" type="xs:float" 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="repeat-start" default="30" type="xs:float" use="optional" />
|
||||||
|
<xs:attribute name="rotate" default="true" type="xs:boolean" use="optional" />
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
|
|
||||||
<xs:complexType name="extrusion">
|
<xs:complexType name="extrusion">
|
||||||
|
|||||||
@@ -1078,7 +1078,7 @@
|
|||||||
<m k="area" v="~|false|no">
|
<m k="area" v="~|false|no">
|
||||||
<m k="highway">
|
<m k="highway">
|
||||||
<m k="oneway" v="yes|true" zoom-min="16">
|
<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>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|||||||
@@ -1038,7 +1038,7 @@
|
|||||||
<m k="area" v="~|false|no">
|
<m k="area" v="~|false|no">
|
||||||
<m k="kind_detail">
|
<m k="kind_detail">
|
||||||
<m k="oneway" v="yes|true" zoom-min="16">
|
<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>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|||||||
@@ -1080,7 +1080,7 @@
|
|||||||
<m k="area" v="~|false|no">
|
<m k="area" v="~|false|no">
|
||||||
<m k="highway">
|
<m k="highway">
|
||||||
<m k="oneway" v="yes|true" zoom-min="16">
|
<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>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|||||||
@@ -328,7 +328,12 @@
|
|||||||
<line outline="motorway" use="highway:z11" />
|
<line outline="motorway" use="highway:z11" />
|
||||||
</m>
|
</m>
|
||||||
</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>
|
||||||
|
|
||||||
<m k="layer" v="transportation_name">
|
<m k="layer" v="transportation_name">
|
||||||
|
|||||||
@@ -982,7 +982,7 @@
|
|||||||
<m k="area" v="~|false|no">
|
<m k="area" v="~|false|no">
|
||||||
<m k="highway">
|
<m k="highway">
|
||||||
<m k="oneway" v="yes|true" zoom-min="16">
|
<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>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|||||||
@@ -982,7 +982,7 @@
|
|||||||
<m k="area" v="~|false|no">
|
<m k="area" v="~|false|no">
|
||||||
<m k="highway">
|
<m k="highway">
|
||||||
<m k="oneway" v="yes|true" zoom-min="16">
|
<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>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|||||||
@@ -1073,7 +1073,7 @@
|
|||||||
<m k="area" v="~|false|no">
|
<m k="area" v="~|false|no">
|
||||||
<m k="highway">
|
<m k="highway">
|
||||||
<m k="oneway" v="yes|true" zoom-min="16">
|
<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>
|
</m>
|
||||||
</m>
|
</m>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2019 devemux86
|
||||||
* Copyright 2018 Gustl22
|
* Copyright 2018 Gustl22
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
@@ -522,7 +522,8 @@ public class LabelPlacement {
|
|||||||
s.texRegion = ti.texRegion;
|
s.texRegion = ti.texRegion;
|
||||||
s.x = x;
|
s.x = x;
|
||||||
s.y = y;
|
s.y = y;
|
||||||
s.billboard = true;
|
s.billboard = ti.billboard;
|
||||||
|
s.rotation = ti.rotation;
|
||||||
sl.addSymbol(s);
|
sl.addSymbol(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2018 devemux86
|
* Copyright 2018-2019 devemux86
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
*
|
*
|
||||||
@@ -63,20 +63,19 @@ public final class WayDecorator {
|
|||||||
previousX += diffX * segmentSkipPercentage;
|
previousX += diffX * segmentSkipPercentage;
|
||||||
previousY += diffY * segmentSkipPercentage;
|
previousY += diffY * segmentSkipPercentage;
|
||||||
|
|
||||||
// TODO
|
if (symbol.rotate) {
|
||||||
/*if (rotate) {
|
|
||||||
// if we do not rotate theta will be 0, which is correct
|
// 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 x = previousX;
|
||||||
float y = previousY;
|
float y = previousY;
|
||||||
if (x >= 0 && x <= Tile.SIZE && y >= 0 && y <= Tile.SIZE) {
|
if (x >= 0 && x <= Tile.SIZE && y >= 0 && y <= Tile.SIZE) {
|
||||||
SymbolItem s = SymbolItem.pool.get();
|
SymbolItem s = SymbolItem.pool.get();
|
||||||
if (symbol.bitmap != null)
|
if (symbol.bitmap != null)
|
||||||
s.set(x, y, symbol.bitmap, 0, true);
|
s.set(x, y, symbol.bitmap, theta, symbol.billboard);
|
||||||
else
|
else
|
||||||
s.set(x, y, symbol.texture, 0, true);
|
s.set(x, y, symbol.texture, theta, symbol.billboard);
|
||||||
ld.symbols.push(s);
|
ld.symbols.push(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1163,6 +1163,9 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
else if ("symbol-scaling".equals(name))
|
else if ("symbol-scaling".equals(name))
|
||||||
; // no-op
|
; // no-op
|
||||||
|
|
||||||
|
else if ("billboard".equals(name))
|
||||||
|
b.billboard(Boolean.parseBoolean(value));
|
||||||
|
|
||||||
else if ("repeat".equals(name))
|
else if ("repeat".equals(name))
|
||||||
b.repeat(Boolean.parseBoolean(value));
|
b.repeat(Boolean.parseBoolean(value));
|
||||||
|
|
||||||
@@ -1172,6 +1175,9 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
else if ("repeat-gap".equals(name))
|
else if ("repeat-gap".equals(name))
|
||||||
b.repeatGap = Float.parseFloat(value) * mScale;
|
b.repeatGap = Float.parseFloat(value) * mScale;
|
||||||
|
|
||||||
|
else if ("rotate".equals(name))
|
||||||
|
b.rotate(Boolean.parseBoolean(value));
|
||||||
|
|
||||||
else
|
else
|
||||||
logUnknownAttribute(elementName, name, value, i);
|
logUnknownAttribute(elementName, name, value, i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.theme.styles;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
|
import org.oscim.backend.CanvasAdapter;
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.backend.canvas.Paint.Cap;
|
import org.oscim.backend.canvas.Paint.Cap;
|
||||||
import org.oscim.renderer.bucket.TextureItem;
|
import org.oscim.renderer.bucket.TextureItem;
|
||||||
@@ -58,15 +59,15 @@ public final class LineStyle extends RenderStyle<LineStyle> {
|
|||||||
public final float repeatGap;
|
public final float repeatGap;
|
||||||
|
|
||||||
public LineStyle(int stroke, float width) {
|
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) {
|
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) {
|
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,
|
public LineStyle(int level, String style, int color, float width,
|
||||||
@@ -328,8 +329,8 @@ public final class LineStyle extends RenderStyle<LineStyle> {
|
|||||||
symbolPercent = 100;
|
symbolPercent = 100;
|
||||||
|
|
||||||
dashArray = null;
|
dashArray = null;
|
||||||
repeatStart = REPEAT_START_DEFAULT;
|
repeatStart = REPEAT_START_DEFAULT * CanvasAdapter.getScale();
|
||||||
repeatGap = REPEAT_GAP_DEFAULT;
|
repeatGap = REPEAT_GAP_DEFAULT * CanvasAdapter.getScale();
|
||||||
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016-2018 devemux86
|
* Copyright 2016-2019 devemux86
|
||||||
* Copyright 2017 Longri
|
* Copyright 2017 Longri
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.theme.styles;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
|
import org.oscim.backend.CanvasAdapter;
|
||||||
import org.oscim.backend.canvas.Bitmap;
|
import org.oscim.backend.canvas.Bitmap;
|
||||||
import org.oscim.renderer.atlas.TextureRegion;
|
import org.oscim.renderer.atlas.TextureRegion;
|
||||||
|
|
||||||
@@ -38,9 +39,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
public final int symbolHeight;
|
public final int symbolHeight;
|
||||||
public final int symbolPercent;
|
public final int symbolPercent;
|
||||||
|
|
||||||
|
public final boolean billboard;
|
||||||
public final boolean repeat;
|
public final boolean repeat;
|
||||||
public final float repeatStart;
|
public final float repeatStart;
|
||||||
public final float repeatGap;
|
public final float repeatGap;
|
||||||
|
public final boolean rotate;
|
||||||
|
|
||||||
public SymbolStyle(Bitmap bitmap) {
|
public SymbolStyle(Bitmap bitmap) {
|
||||||
this(bitmap, null, 0);
|
this(bitmap, null, 0);
|
||||||
@@ -63,9 +66,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
this.symbolHeight = 0;
|
this.symbolHeight = 0;
|
||||||
this.symbolPercent = 100;
|
this.symbolPercent = 100;
|
||||||
|
|
||||||
|
this.billboard = false;
|
||||||
this.repeat = false;
|
this.repeat = false;
|
||||||
this.repeatStart = REPEAT_START_DEFAULT;
|
this.repeatStart = REPEAT_START_DEFAULT * CanvasAdapter.getScale();
|
||||||
this.repeatGap = REPEAT_GAP_DEFAULT;
|
this.repeatGap = REPEAT_GAP_DEFAULT * CanvasAdapter.getScale();
|
||||||
|
this.rotate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SymbolStyle(SymbolBuilder<?> b) {
|
public SymbolStyle(SymbolBuilder<?> b) {
|
||||||
@@ -79,9 +84,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
this.symbolHeight = b.symbolHeight;
|
this.symbolHeight = b.symbolHeight;
|
||||||
this.symbolPercent = b.symbolPercent;
|
this.symbolPercent = b.symbolPercent;
|
||||||
|
|
||||||
|
this.billboard = b.billboard;
|
||||||
this.repeat = b.repeat;
|
this.repeat = b.repeat;
|
||||||
this.repeatStart = b.repeatStart;
|
this.repeatStart = b.repeatStart;
|
||||||
this.repeatGap = b.repeatGap;
|
this.repeatGap = b.repeatGap;
|
||||||
|
this.rotate = b.rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,9 +122,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
public int symbolHeight;
|
public int symbolHeight;
|
||||||
public int symbolPercent;
|
public int symbolPercent;
|
||||||
|
|
||||||
|
public boolean billboard;
|
||||||
public boolean repeat;
|
public boolean repeat;
|
||||||
public float repeatStart;
|
public float repeatStart;
|
||||||
public float repeatGap;
|
public float repeatGap;
|
||||||
|
public boolean rotate;
|
||||||
|
|
||||||
public SymbolBuilder() {
|
public SymbolBuilder() {
|
||||||
}
|
}
|
||||||
@@ -136,9 +145,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
this.symbolHeight = symbol.symbolHeight;
|
this.symbolHeight = symbol.symbolHeight;
|
||||||
this.symbolPercent = symbol.symbolPercent;
|
this.symbolPercent = symbol.symbolPercent;
|
||||||
|
|
||||||
|
this.billboard = symbol.billboard;
|
||||||
this.repeat = symbol.repeat;
|
this.repeat = symbol.repeat;
|
||||||
this.repeatStart = symbol.repeatStart;
|
this.repeatStart = symbol.repeatStart;
|
||||||
this.repeatGap = symbol.repeatGap;
|
this.repeatGap = symbol.repeatGap;
|
||||||
|
this.rotate = symbol.rotate;
|
||||||
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
@@ -173,6 +184,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T billboard(boolean billboard) {
|
||||||
|
this.billboard = billboard;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public T repeat(boolean repeat) {
|
public T repeat(boolean repeat) {
|
||||||
this.repeat = repeat;
|
this.repeat = repeat;
|
||||||
return self();
|
return self();
|
||||||
@@ -188,6 +204,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T rotate(boolean rotate) {
|
||||||
|
this.rotate = rotate;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public T reset() {
|
public T reset() {
|
||||||
cat = null;
|
cat = null;
|
||||||
|
|
||||||
@@ -199,9 +220,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
|
|||||||
symbolHeight = 0;
|
symbolHeight = 0;
|
||||||
symbolPercent = 100;
|
symbolPercent = 100;
|
||||||
|
|
||||||
|
billboard = false;
|
||||||
repeat = false;
|
repeat = false;
|
||||||
repeatStart = REPEAT_START_DEFAULT;
|
repeatStart = REPEAT_START_DEFAULT * CanvasAdapter.getScale();
|
||||||
repeatGap = REPEAT_GAP_DEFAULT;
|
repeatGap = REPEAT_GAP_DEFAULT * CanvasAdapter.getScale();
|
||||||
|
rotate = true;
|
||||||
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user