From db9f83120a4bb3af9bdfd51d3294aaa8a88c2417 Mon Sep 17 00:00:00 2001 From: Emux Date: Sat, 28 Sep 2019 18:24:38 +0300 Subject: [PATCH 1/4] Render themes - symbols on lines: add billboard, rotate options --- resources/rendertheme.xsd | 2 ++ .../tile/vector/labeling/LabelPlacement.java | 5 ++-- .../tile/vector/labeling/WayDecorator.java | 13 +++++----- vtm/src/org/oscim/theme/XmlThemeBuilder.java | 6 +++++ .../org/oscim/theme/styles/SymbolStyle.java | 24 ++++++++++++++++++- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/resources/rendertheme.xsd b/resources/rendertheme.xsd index a388561f..0bf0aac9 100644 --- a/resources/rendertheme.xsd +++ b/resources/rendertheme.xsd @@ -237,9 +237,11 @@ + + diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java index 0d96f4dd..2097253e 100644 --- a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java +++ b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java @@ -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); } } diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java b/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java index 4a3e4862..f6bf1f2e 100644 --- a/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java +++ b/vtm/src/org/oscim/layers/tile/vector/labeling/WayDecorator.java @@ -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); } diff --git a/vtm/src/org/oscim/theme/XmlThemeBuilder.java b/vtm/src/org/oscim/theme/XmlThemeBuilder.java index c410c203..2adf60c8 100644 --- a/vtm/src/org/oscim/theme/XmlThemeBuilder.java +++ b/vtm/src/org/oscim/theme/XmlThemeBuilder.java @@ -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); } diff --git a/vtm/src/org/oscim/theme/styles/SymbolStyle.java b/vtm/src/org/oscim/theme/styles/SymbolStyle.java index 807ba87f..53192009 100644 --- a/vtm/src/org/oscim/theme/styles/SymbolStyle.java +++ b/vtm/src/org/oscim/theme/styles/SymbolStyle.java @@ -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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 { symbolHeight = 0; symbolPercent = 100; + billboard = false; repeat = false; repeatStart = REPEAT_START_DEFAULT; repeatGap = REPEAT_GAP_DEFAULT; + rotate = true; return self(); } From 2cb0a80c4772a5e8de19be75e332287ca7006be5 Mon Sep 17 00:00:00 2001 From: Emux Date: Sat, 28 Sep 2019 19:38:22 +0300 Subject: [PATCH 2/4] LineStyle, SymbolStyle: use scale on repeat values --- vtm/src/org/oscim/theme/styles/LineStyle.java | 11 ++++++----- vtm/src/org/oscim/theme/styles/SymbolStyle.java | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/vtm/src/org/oscim/theme/styles/LineStyle.java b/vtm/src/org/oscim/theme/styles/LineStyle.java index 513b8166..75803f81 100644 --- a/vtm/src/org/oscim/theme/styles/LineStyle.java +++ b/vtm/src/org/oscim/theme/styles/LineStyle.java @@ -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 { 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 { 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(); } diff --git a/vtm/src/org/oscim/theme/styles/SymbolStyle.java b/vtm/src/org/oscim/theme/styles/SymbolStyle.java index 53192009..2267426a 100644 --- a/vtm/src/org/oscim/theme/styles/SymbolStyle.java +++ b/vtm/src/org/oscim/theme/styles/SymbolStyle.java @@ -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; @@ -67,8 +68,8 @@ public final class SymbolStyle extends RenderStyle { 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; } @@ -221,8 +222,8 @@ public final class SymbolStyle extends RenderStyle { 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(); From 107a429517d0964fe84970e7d8581bda3a63a52d Mon Sep 17 00:00:00 2001 From: Emux Date: Sat, 28 Sep 2019 19:38:54 +0300 Subject: [PATCH 3/4] Render themes: use symbols on lines for oneways --- vtm-themes/resources/assets/vtm/default.xml | 2 +- vtm-themes/resources/assets/vtm/mapzen.xml | 2 +- vtm-themes/resources/assets/vtm/newtron.xml | 2 +- vtm-themes/resources/assets/vtm/openmaptiles.xml | 7 ++++++- vtm-themes/resources/assets/vtm/osmagray.xml | 2 +- vtm-themes/resources/assets/vtm/osmarender.xml | 2 +- vtm-themes/resources/assets/vtm/tronrender.xml | 2 +- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/vtm-themes/resources/assets/vtm/default.xml b/vtm-themes/resources/assets/vtm/default.xml index 70d4a24d..dba79c32 100644 --- a/vtm-themes/resources/assets/vtm/default.xml +++ b/vtm-themes/resources/assets/vtm/default.xml @@ -1078,7 +1078,7 @@ - + diff --git a/vtm-themes/resources/assets/vtm/mapzen.xml b/vtm-themes/resources/assets/vtm/mapzen.xml index d28f86ba..dba5cfe1 100644 --- a/vtm-themes/resources/assets/vtm/mapzen.xml +++ b/vtm-themes/resources/assets/vtm/mapzen.xml @@ -1038,7 +1038,7 @@ - + diff --git a/vtm-themes/resources/assets/vtm/newtron.xml b/vtm-themes/resources/assets/vtm/newtron.xml index 83b20d07..c44886b1 100644 --- a/vtm-themes/resources/assets/vtm/newtron.xml +++ b/vtm-themes/resources/assets/vtm/newtron.xml @@ -1080,7 +1080,7 @@ - + diff --git a/vtm-themes/resources/assets/vtm/openmaptiles.xml b/vtm-themes/resources/assets/vtm/openmaptiles.xml index d5e97e15..1155c268 100644 --- a/vtm-themes/resources/assets/vtm/openmaptiles.xml +++ b/vtm-themes/resources/assets/vtm/openmaptiles.xml @@ -328,7 +328,12 @@ - + + + + + + diff --git a/vtm-themes/resources/assets/vtm/osmagray.xml b/vtm-themes/resources/assets/vtm/osmagray.xml index 0a607bbc..b2e00d9b 100644 --- a/vtm-themes/resources/assets/vtm/osmagray.xml +++ b/vtm-themes/resources/assets/vtm/osmagray.xml @@ -982,7 +982,7 @@ - + diff --git a/vtm-themes/resources/assets/vtm/osmarender.xml b/vtm-themes/resources/assets/vtm/osmarender.xml index 0ad9fbf8..fa74a504 100644 --- a/vtm-themes/resources/assets/vtm/osmarender.xml +++ b/vtm-themes/resources/assets/vtm/osmarender.xml @@ -982,7 +982,7 @@ - + diff --git a/vtm-themes/resources/assets/vtm/tronrender.xml b/vtm-themes/resources/assets/vtm/tronrender.xml index 0eaed763..a5d139b9 100644 --- a/vtm-themes/resources/assets/vtm/tronrender.xml +++ b/vtm-themes/resources/assets/vtm/tronrender.xml @@ -1073,7 +1073,7 @@ - + From c5836adc17583836442a618683b4500b94d53de3 Mon Sep 17 00:00:00 2001 From: Emux Date: Sat, 28 Sep 2019 19:44:29 +0300 Subject: [PATCH 4/4] Update changelog --- docs/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Changelog.md b/docs/Changelog.md index 574a5371..74030a80 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -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)