BuildingLayer: tag-transform color values (#683)
This commit is contained in:
parent
73e17ef4a1
commit
7498d58878
@ -270,6 +270,9 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook, ZoomLim
|
|||||||
return mExtrusionRenderer;
|
return mExtrusionRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the tile source tag key or library tag key as fallback
|
||||||
|
*/
|
||||||
protected String getKeyOrDefault(String key) {
|
protected String getKeyOrDefault(String key) {
|
||||||
if (mTileLayer.getTheme() == null)
|
if (mTileLayer.getTheme() == null)
|
||||||
return key;
|
return key;
|
||||||
@ -277,6 +280,35 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook, ZoomLim
|
|||||||
return res != null ? res : key;
|
return res != null ? res : key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the forward transformed value from tile source tag via the library tag key.
|
||||||
|
*
|
||||||
|
* @param key the library tag key
|
||||||
|
* @return the tile source tag value transformed to library tag value
|
||||||
|
*/
|
||||||
|
protected String getTransformedValue(MapElement element, String key) {
|
||||||
|
if (mTileLayer.getTheme() == null)
|
||||||
|
return element.tags.getValue(key);
|
||||||
|
/* Get tile source key of specified lib key from theme or fall back to lib key */
|
||||||
|
key = getKeyOrDefault(key);
|
||||||
|
/* Get element tag with tile source key, if exists */
|
||||||
|
Tag tsTag = element.tags.get(key);
|
||||||
|
if (tsTag == null)
|
||||||
|
return null;
|
||||||
|
/* Transform tile source tag to lib tag */
|
||||||
|
Tag libTag = mTileLayer.getTheme().transformForwardTag(tsTag);
|
||||||
|
if (libTag != null)
|
||||||
|
return libTag.value;
|
||||||
|
/* Use tile source value, if transformation rule not exists */
|
||||||
|
return tsTag.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the tile source tag value via the library tag key.
|
||||||
|
*
|
||||||
|
* @param key the library tag key
|
||||||
|
* @return the tile source tag value of specified library tag key
|
||||||
|
*/
|
||||||
protected String getValue(MapElement element, String key) {
|
protected String getValue(MapElement element, String key) {
|
||||||
return element.tags.getValue(getKeyOrDefault(key));
|
return element.tags.getValue(getKeyOrDefault(key));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 Gustl22
|
* Copyright 2018-2019 Gustl22
|
||||||
* Copyright 2018-2019 devemux86
|
* Copyright 2018-2019 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
@ -158,9 +158,9 @@ public class S3DBLayer extends BuildingLayer {
|
|||||||
// Get building color
|
// Get building color
|
||||||
Integer bColor = null;
|
Integer bColor = null;
|
||||||
if (mColored) {
|
if (mColored) {
|
||||||
if ((v = getValue(element, Tag.KEY_BUILDING_COLOR)) != null) {
|
if ((v = getTransformedValue(element, Tag.KEY_BUILDING_COLOR)) != null) {
|
||||||
bColor = S3DBUtils.getColor(v, false, false);
|
bColor = S3DBUtils.getColor(v, false, false);
|
||||||
} else if ((v = getValue(element, Tag.KEY_BUILDING_MATERIAL)) != null) {
|
} else if ((v = getTransformedValue(element, Tag.KEY_BUILDING_MATERIAL)) != null) {
|
||||||
bColor = S3DBUtils.getMaterialColor(v, false);
|
bColor = S3DBUtils.getMaterialColor(v, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,10 +261,10 @@ public class S3DBLayer extends BuildingLayer {
|
|||||||
String v;
|
String v;
|
||||||
|
|
||||||
if (mColored) {
|
if (mColored) {
|
||||||
v = getValue(element, Tag.KEY_ROOF_COLOR);
|
v = getTransformedValue(element, Tag.KEY_ROOF_COLOR);
|
||||||
if (v != null)
|
if (v != null)
|
||||||
roofColor = S3DBUtils.getColor(v, true, false);
|
roofColor = S3DBUtils.getColor(v, true, false);
|
||||||
else if ((v = getValue(element, Tag.KEY_ROOF_MATERIAL)) != null)
|
else if ((v = getTransformedValue(element, Tag.KEY_ROOF_MATERIAL)) != null)
|
||||||
roofColor = S3DBUtils.getMaterialColor(v, true);
|
roofColor = S3DBUtils.getMaterialColor(v, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user