Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-10-24 14:46:24 +02:00
commit b269515866
4 changed files with 60 additions and 34 deletions

View file

@ -61,13 +61,13 @@ public class BinaryInspector {
if(args.length == 1 && "test".equals(args[0])) { if(args.length == 1 && "test".equals(args[0])) {
in.inspector(new String[]{ in.inspector(new String[]{
//"-vpoi", //"-vpoi",
"-vmap", "-vmapobjects", // "-vmap", "-vmapobjects",
// "-vrouting", // "-vrouting",
// "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings", // "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings",
//"-zoom=16", //"-zoom=16",
//"-bbox=4,55,7,50", //"-bbox=4,55,7,50",
"/home/victor/projects/osmand/osm-gen/Map.obf" // "/home/victor/projects/osmand/osm-gen/Map.obf"
// "/home/victor/projects/osmand/osm-gen/Netherlands_europe.obf" "/home/victor/projects/osmand/osm-gen/Ukraine_europe.obf"
// "/home/victor/projects/osmand/osm-gen/World_basemap_2_b.obf___" // "/home/victor/projects/osmand/osm-gen/World_basemap_2_b.obf___"
// "/home/victor/projects/osmand/osm-gen/World_basemap_2.obf__" // "/home/victor/projects/osmand/osm-gen/World_basemap_2.obf__"
}); });

View file

@ -14,6 +14,7 @@ public class RenderingRule {
private RenderingRuleProperty[] properties; private RenderingRuleProperty[] properties;
private int[] intProperties; private int[] intProperties;
private RenderingRule[] attributesRef;
private float[] floatProperties; private float[] floatProperties;
private List<RenderingRule> ifElseChildren; private List<RenderingRule> ifElseChildren;
private List<RenderingRule> ifChildren; private List<RenderingRule> ifChildren;
@ -41,6 +42,7 @@ public class RenderingRule {
ArrayList<RenderingRuleProperty> props = new ArrayList<RenderingRuleProperty>(attributes.size()); ArrayList<RenderingRuleProperty> props = new ArrayList<RenderingRuleProperty>(attributes.size());
intProperties = new int[attributes.size()]; intProperties = new int[attributes.size()];
floatProperties = null; floatProperties = null;
attributesRef = null;
int i = 0; int i = 0;
Iterator<Entry<String, String>> it = attributes.entrySet().iterator(); Iterator<Entry<String, String>> it = attributes.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
@ -48,18 +50,23 @@ public class RenderingRule {
RenderingRuleProperty property = storage.PROPS.get(e.getKey()); RenderingRuleProperty property = storage.PROPS.get(e.getKey());
if (property != null) { if (property != null) {
props.add(property); props.add(property);
String vl = e.getValue();
if (property.isString()) { if(vl.startsWith("$")){
intProperties[i] = storage.getDictionaryValue(e.getValue()); if (attributesRef == null) {
attributesRef = new RenderingRule[attributes.size()];
}
attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1));
} else if (property.isString()) {
intProperties[i] = storage.getDictionaryValue(vl);
} else if (property.isFloat()) { } else if (property.isFloat()) {
if (floatProperties == null) { if (floatProperties == null) {
// lazy creates // lazy creates
floatProperties = new float[attributes.size()]; floatProperties = new float[attributes.size()];
} }
floatProperties[i] = property.parseFloatValue(e.getValue()); floatProperties[i] = property.parseFloatValue(vl);
intProperties[i] = property.parseIntValue(e.getValue()); intProperties[i] = property.parseIntValue(vl);
} else { } else {
intProperties[i] = property.parseIntValue(e.getValue()); intProperties[i] = property.parseIntValue(vl);
} }
i++; i++;
} }
@ -114,6 +121,13 @@ public class RenderingRule {
return intProperties[ind]; return intProperties[ind];
} }
protected RenderingRule getAttrProp(int ind) {
if(attributesRef == null) {
return null;
}
return attributesRef[ind];
}
protected float getFloatProp(int ind){ protected float getFloatProp(int ind){
return floatProperties[ind]; return floatProperties[ind];
} }

View file

@ -157,7 +157,7 @@ public class RenderingRuleSearchRequest {
if(!input) { if(!input) {
return false; return false;
} }
if (!loadOutput) { if (!loadOutput && !rule.isGroup()) {
return true; return true;
} }
// accept it // accept it
@ -171,7 +171,8 @@ public class RenderingRuleSearchRequest {
break; break;
} }
} }
if (match || !rule.isGroup()) { boolean fit = (match || !rule.isGroup());
if (fit && loadOutput) {
if (rule.isGroup()) { if (rule.isGroup()) {
loadOutputProperties(rule, false); loadOutputProperties(rule, false);
} }
@ -179,9 +180,8 @@ public class RenderingRuleSearchRequest {
for (RenderingRule rr : rule.getIfChildren()) { for (RenderingRule rr : rule.getIfChildren()) {
visitRule(rr, loadOutput); visitRule(rr, loadOutput);
} }
return true;
} }
return false; return fit;
} }
@ -191,7 +191,16 @@ public class RenderingRuleSearchRequest {
RenderingRuleProperty rp = properties[i]; RenderingRuleProperty rp = properties[i];
if (rp.isOutputProperty()) { if (rp.isOutputProperty()) {
if (!isSpecified(rp) || override) { if (!isSpecified(rp) || override) {
if (rp.isFloat()) { RenderingRule rr = rule.getAttrProp(i);
if(rr != null) {
visitRule(rr, true);
if(isSpecified(storage.PROPS.R_ATTR_COLOR_VALUE)){
values[rp.getId()] = getIntPropertyValue(storage.PROPS.R_ATTR_COLOR_VALUE);
} else if(isSpecified(storage.PROPS.R_ATTR_INT_VALUE)){
values[rp.getId()] = getIntPropertyValue(storage.PROPS.R_ATTR_INT_VALUE);
fvalues[rp.getId()] = getFloatPropertyValue(storage.PROPS.R_ATTR_INT_VALUE);
}
} else if (rp.isFloat()) {
fvalues[rp.getId()] = rule.getFloatProp(i); fvalues[rp.getId()] = rule.getFloatProp(i);
values[rp.getId()] = rule.getIntProp(i); values[rp.getId()] = rule.getIntProp(i);
} else { } else {

View file

@ -48,7 +48,7 @@ public class RenderingRulesStorage {
public TIntObjectHashMap<RenderingRule>[] tagValueGlobalRules = new TIntObjectHashMap[LENGTH_RULES]; public TIntObjectHashMap<RenderingRule>[] tagValueGlobalRules = new TIntObjectHashMap[LENGTH_RULES];
protected Map<String, RenderingRule> renderingAttributes = new LinkedHashMap<String, RenderingRule>(); protected Map<String, RenderingRule> renderingAttributes = new LinkedHashMap<String, RenderingRule>();
protected Map<String, String> renderingConstants= new LinkedHashMap<String, String>(); protected Map<String, String> renderingConstants = new LinkedHashMap<String, String>();
private String renderingName; private String renderingName;
private String internalRenderingName; private String internalRenderingName;
@ -335,10 +335,13 @@ public class RenderingRulesStorage {
String vl = parser.getAttributeValue(i); String vl = parser.getAttributeValue(i);
if (vl != null && vl.startsWith("$")) { if (vl != null && vl.startsWith("$")) {
String cv = vl.substring(1); String cv = vl.substring(1);
if (!renderingConstants.containsKey(cv)) { if (!renderingConstants.containsKey(cv) &&
throw new IllegalStateException("Rendering constant '" + cv + "' was not specified."); !renderingAttributes.containsKey(cv)) {
throw new IllegalStateException("Rendering constant or attribute '" + cv + "' was not specified.");
}
if(renderingConstants.containsKey(cv)){
vl = renderingConstants.get(cv);
} }
vl = renderingConstants.get(cv);
} }
m.put(name, vl); m.put(name, vl);
} }
@ -470,7 +473,7 @@ public class RenderingRulesStorage {
}; };
storage.parseRulesFromXmlInputStream(is, resolver); storage.parseRulesFromXmlInputStream(is, resolver);
printAllRules(storage); // printAllRules(storage);
testSearch(storage); testSearch(storage);
} }
@ -479,22 +482,22 @@ public class RenderingRulesStorage {
// int count = 100000; // int count = 100000;
// for (int i = 0; i < count; i++) { // for (int i = 0; i < count; i++) {
RenderingRuleSearchRequest searchRequest = new RenderingRuleSearchRequest(storage); RenderingRuleSearchRequest searchRequest = new RenderingRuleSearchRequest(storage);
searchRequest.setStringFilter(storage.PROPS.R_TAG, "natural"); searchRequest.setStringFilter(storage.PROPS.R_TAG, "highway");
searchRequest.setStringFilter(storage.PROPS.R_VALUE, "tree"); searchRequest.setStringFilter(storage.PROPS.R_VALUE, "primary");
searchRequest.setStringFilter(storage.PROPS.R_ADDITIONAL, "leaf_type=broadleaved"); // searchRequest.setStringFilter(storage.PROPS.R_ADDITIONAL, "leaf_type=broadleaved");
// searchRequest.setIntFilter(storage.PROPS.R_LAYER, 1); // searchRequest.setIntFilter(storage.PROPS.R_LAYER, 1);
searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 18); searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 9);
searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 18); searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 9);
// searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true); // searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true);
// searchRequest.setBooleanFilter(storage.PROPS.get("hmRendered"), true); // for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) { // if (customProp.isBoolean()) {
if (customProp.isBoolean()) { // searchRequest.setBooleanFilter(customProp, false);
searchRequest.setBooleanFilter(customProp, false); // } else {
} else { // searchRequest.setStringFilter(customProp, "");
searchRequest.setStringFilter(customProp, ""); // }
} // }
} searchRequest.setBooleanFilter(storage.PROPS.get("noPolygons"), true);
boolean res = searchRequest.search(POINT_RULES); boolean res = searchRequest.search(LINE_RULES);
System.out.println("Result " + res); System.out.println("Result " + res);
printResult(searchRequest, System.out); printResult(searchRequest, System.out);
// } // }