Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
b269515866
4 changed files with 60 additions and 34 deletions
|
@ -61,13 +61,13 @@ public class BinaryInspector {
|
|||
if(args.length == 1 && "test".equals(args[0])) {
|
||||
in.inspector(new String[]{
|
||||
//"-vpoi",
|
||||
"-vmap", "-vmapobjects",
|
||||
// "-vmap", "-vmapobjects",
|
||||
// "-vrouting",
|
||||
// "-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings",
|
||||
//"-zoom=16",
|
||||
//"-bbox=4,55,7,50",
|
||||
"/home/victor/projects/osmand/osm-gen/Map.obf"
|
||||
// "/home/victor/projects/osmand/osm-gen/Netherlands_europe.obf"
|
||||
// "/home/victor/projects/osmand/osm-gen/Map.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.obf__"
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ public class RenderingRule {
|
|||
|
||||
private RenderingRuleProperty[] properties;
|
||||
private int[] intProperties;
|
||||
private RenderingRule[] attributesRef;
|
||||
private float[] floatProperties;
|
||||
private List<RenderingRule> ifElseChildren;
|
||||
private List<RenderingRule> ifChildren;
|
||||
|
@ -41,6 +42,7 @@ public class RenderingRule {
|
|||
ArrayList<RenderingRuleProperty> props = new ArrayList<RenderingRuleProperty>(attributes.size());
|
||||
intProperties = new int[attributes.size()];
|
||||
floatProperties = null;
|
||||
attributesRef = null;
|
||||
int i = 0;
|
||||
Iterator<Entry<String, String>> it = attributes.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
|
@ -48,18 +50,23 @@ public class RenderingRule {
|
|||
RenderingRuleProperty property = storage.PROPS.get(e.getKey());
|
||||
if (property != null) {
|
||||
props.add(property);
|
||||
|
||||
if (property.isString()) {
|
||||
intProperties[i] = storage.getDictionaryValue(e.getValue());
|
||||
String vl = e.getValue();
|
||||
if(vl.startsWith("$")){
|
||||
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()) {
|
||||
if (floatProperties == null) {
|
||||
// lazy creates
|
||||
floatProperties = new float[attributes.size()];
|
||||
}
|
||||
floatProperties[i] = property.parseFloatValue(e.getValue());
|
||||
intProperties[i] = property.parseIntValue(e.getValue());
|
||||
floatProperties[i] = property.parseFloatValue(vl);
|
||||
intProperties[i] = property.parseIntValue(vl);
|
||||
} else {
|
||||
intProperties[i] = property.parseIntValue(e.getValue());
|
||||
intProperties[i] = property.parseIntValue(vl);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -114,6 +121,13 @@ public class RenderingRule {
|
|||
return intProperties[ind];
|
||||
}
|
||||
|
||||
protected RenderingRule getAttrProp(int ind) {
|
||||
if(attributesRef == null) {
|
||||
return null;
|
||||
}
|
||||
return attributesRef[ind];
|
||||
}
|
||||
|
||||
protected float getFloatProp(int ind){
|
||||
return floatProperties[ind];
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ public class RenderingRuleSearchRequest {
|
|||
if(!input) {
|
||||
return false;
|
||||
}
|
||||
if (!loadOutput) {
|
||||
if (!loadOutput && !rule.isGroup()) {
|
||||
return true;
|
||||
}
|
||||
// accept it
|
||||
|
@ -171,7 +171,8 @@ public class RenderingRuleSearchRequest {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (match || !rule.isGroup()) {
|
||||
boolean fit = (match || !rule.isGroup());
|
||||
if (fit && loadOutput) {
|
||||
if (rule.isGroup()) {
|
||||
loadOutputProperties(rule, false);
|
||||
}
|
||||
|
@ -179,9 +180,8 @@ public class RenderingRuleSearchRequest {
|
|||
for (RenderingRule rr : rule.getIfChildren()) {
|
||||
visitRule(rr, loadOutput);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return fit;
|
||||
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,16 @@ public class RenderingRuleSearchRequest {
|
|||
RenderingRuleProperty rp = properties[i];
|
||||
if (rp.isOutputProperty()) {
|
||||
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);
|
||||
values[rp.getId()] = rule.getIntProp(i);
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,7 @@ public class RenderingRulesStorage {
|
|||
public TIntObjectHashMap<RenderingRule>[] tagValueGlobalRules = new TIntObjectHashMap[LENGTH_RULES];
|
||||
|
||||
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 internalRenderingName;
|
||||
|
@ -335,10 +335,13 @@ public class RenderingRulesStorage {
|
|||
String vl = parser.getAttributeValue(i);
|
||||
if (vl != null && vl.startsWith("$")) {
|
||||
String cv = vl.substring(1);
|
||||
if (!renderingConstants.containsKey(cv)) {
|
||||
throw new IllegalStateException("Rendering constant '" + cv + "' was not specified.");
|
||||
if (!renderingConstants.containsKey(cv) &&
|
||||
!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);
|
||||
}
|
||||
|
@ -470,7 +473,7 @@ public class RenderingRulesStorage {
|
|||
};
|
||||
storage.parseRulesFromXmlInputStream(is, resolver);
|
||||
|
||||
printAllRules(storage);
|
||||
// printAllRules(storage);
|
||||
testSearch(storage);
|
||||
}
|
||||
|
||||
|
@ -479,22 +482,22 @@ public class RenderingRulesStorage {
|
|||
// int count = 100000;
|
||||
// for (int i = 0; i < count; i++) {
|
||||
RenderingRuleSearchRequest searchRequest = new RenderingRuleSearchRequest(storage);
|
||||
searchRequest.setStringFilter(storage.PROPS.R_TAG, "natural");
|
||||
searchRequest.setStringFilter(storage.PROPS.R_VALUE, "tree");
|
||||
searchRequest.setStringFilter(storage.PROPS.R_ADDITIONAL, "leaf_type=broadleaved");
|
||||
searchRequest.setStringFilter(storage.PROPS.R_TAG, "highway");
|
||||
searchRequest.setStringFilter(storage.PROPS.R_VALUE, "primary");
|
||||
// searchRequest.setStringFilter(storage.PROPS.R_ADDITIONAL, "leaf_type=broadleaved");
|
||||
// searchRequest.setIntFilter(storage.PROPS.R_LAYER, 1);
|
||||
searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 18);
|
||||
searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 18);
|
||||
// searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true);
|
||||
// searchRequest.setBooleanFilter(storage.PROPS.get("hmRendered"), true);
|
||||
for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
|
||||
if (customProp.isBoolean()) {
|
||||
searchRequest.setBooleanFilter(customProp, false);
|
||||
} else {
|
||||
searchRequest.setStringFilter(customProp, "");
|
||||
}
|
||||
}
|
||||
boolean res = searchRequest.search(POINT_RULES);
|
||||
searchRequest.setIntFilter(storage.PROPS.R_MINZOOM, 9);
|
||||
searchRequest.setIntFilter(storage.PROPS.R_MAXZOOM, 9);
|
||||
// searchRequest.setBooleanFilter(storage.PROPS.R_NIGHT_MODE, true);
|
||||
// for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
|
||||
// if (customProp.isBoolean()) {
|
||||
// searchRequest.setBooleanFilter(customProp, false);
|
||||
// } else {
|
||||
// searchRequest.setStringFilter(customProp, "");
|
||||
// }
|
||||
// }
|
||||
searchRequest.setBooleanFilter(storage.PROPS.get("noPolygons"), true);
|
||||
boolean res = searchRequest.search(LINE_RULES);
|
||||
System.out.println("Result " + res);
|
||||
printResult(searchRequest, System.out);
|
||||
// }
|
||||
|
|
Loading…
Reference in a new issue