Render themes - symbols on lines: add billboard, rotate options

This commit is contained in:
Emux 2019-09-28 18:24:38 +03:00
parent 5facdb9888
commit db9f83120a
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
5 changed files with 40 additions and 10 deletions

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

@ -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

@ -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).
@ -38,9 +38,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 +65,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.rotate = true;
}
public SymbolStyle(SymbolBuilder<?> b) {
@ -79,9 +83,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 +121,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 +144,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 +183,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 +203,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 +219,11 @@ public final class SymbolStyle extends RenderStyle<SymbolStyle> {
symbolHeight = 0;
symbolPercent = 100;
billboard = false;
repeat = false;
repeatStart = REPEAT_START_DEFAULT;
repeatGap = REPEAT_GAP_DEFAULT;
rotate = true;
return self();
}