Render themes: rule types order, fix #418
This commit is contained in:
parent
3d92807d26
commit
60aa9600d8
@ -429,7 +429,7 @@ public class XmlMapsforgeThemeBuilder extends DefaultHandler {
|
|||||||
if (zoomMin > zoomMax)
|
if (zoomMin > zoomMax)
|
||||||
throw new ThemeException("zoom-min must be less or equal zoom-max: " + zoomMin);
|
throw new ThemeException("zoom-min must be less or equal zoom-max: " + zoomMin);
|
||||||
|
|
||||||
RuleBuilder b = RuleBuilder.create(keys, values, true);
|
RuleBuilder b = RuleBuilder.create(keys, values);
|
||||||
b.cat(cat);
|
b.cat(cat);
|
||||||
b.zoom(zoomMin, zoomMax);
|
b.zoom(zoomMin, zoomMax);
|
||||||
b.element(element);
|
b.element(element);
|
||||||
|
@ -28,7 +28,9 @@ import org.oscim.theme.styles.RenderStyle;
|
|||||||
import org.oscim.theme.styles.RenderStyle.StyleBuilder;
|
import org.oscim.theme.styles.RenderStyle.StyleBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RuleBuilder {
|
public class RuleBuilder {
|
||||||
|
|
||||||
@ -85,45 +87,35 @@ public class RuleBuilder {
|
|||||||
this.values = EMPTY_KV;
|
this.values = EMPTY_KV;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RuleBuilder create(String keys, String values) {
|
public static RuleBuilder create(String k, String v) {
|
||||||
return create(keys, values, false);
|
String[] keys = EMPTY_KV;
|
||||||
}
|
String[] values = EMPTY_KV;
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapsforge themes don't support (-) 'exclusive negation'.
|
|
||||||
*/
|
|
||||||
public static RuleBuilder create(String keys, String values, boolean isMapsforge) {
|
|
||||||
|
|
||||||
String[] keyList = EMPTY_KV;
|
|
||||||
String[] valueList = EMPTY_KV;
|
|
||||||
RuleType type = RuleType.POSITIVE;
|
RuleType type = RuleType.POSITIVE;
|
||||||
|
|
||||||
if (values != null) {
|
if (v != null) {
|
||||||
if (values.startsWith(STRING_NEGATION)) {
|
String[] split = v.split(SEPARATOR);
|
||||||
|
List<String> valueList = new ArrayList<>(Arrays.asList(split));
|
||||||
|
if (valueList.remove(STRING_NEGATION)) {
|
||||||
type = RuleType.NEGATIVE;
|
type = RuleType.NEGATIVE;
|
||||||
if (values.length() > 2)
|
values = valueList.toArray(new String[valueList.size()]);
|
||||||
valueList = values.substring(2)
|
} else if (valueList.remove(STRING_EXCLUSIVE)) {
|
||||||
.split(SEPARATOR);
|
|
||||||
} else if (values.startsWith(STRING_EXCLUSIVE) && !isMapsforge) {
|
|
||||||
type = RuleType.EXCLUDE;
|
type = RuleType.EXCLUDE;
|
||||||
if (values.length() > 2)
|
values = valueList.toArray(new String[valueList.size()]);
|
||||||
valueList = values.substring(2)
|
|
||||||
.split(SEPARATOR);
|
|
||||||
} else {
|
} else {
|
||||||
valueList = values.split(SEPARATOR);
|
values = split;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys != null) {
|
if (k != null) {
|
||||||
keyList = keys.split(SEPARATOR);
|
keys = k.split(SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != RuleType.POSITIVE) {
|
if (type != RuleType.POSITIVE) {
|
||||||
if (keyList == null || keyList.length == 0)
|
if (keys == null || keys.length == 0)
|
||||||
throw new ThemeException("negative rule requires key");
|
throw new ThemeException("negative rule requires key");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RuleBuilder(type, keyList, valueList);
|
return new RuleBuilder(type, keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RuleBuilder zoom(byte zoomMin, byte zoomMax) {
|
public RuleBuilder zoom(byte zoomMin, byte zoomMax) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user