use of net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapEncodingRule in project OsmAnd-tools by osmandapp.
the class BinaryMapIndexWriter method writeMapEncodingRules.
public void writeMapEncodingRules(TIntObjectMap<TagValuePair> decodingRules) throws IOException {
for (int i = 1; i <= decodingRules.size(); i++) {
TagValuePair value = decodingRules.get(i);
MapEncodingRule.Builder builder = OsmandOdb.OsmAndMapIndex.MapEncodingRule.newBuilder();
if (value == null) {
break;
}
builder.setTag(value.tag);
if (value.value != null) {
builder.setValue(value.value);
}
builder.setType(value.additionalAttribute);
MapEncodingRule rulet = builder.build();
codedOutStream.writeMessage(OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER, rulet);
}
}
use of net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapEncodingRule in project OsmAnd-tools by osmandapp.
the class BinaryMapIndexWriter method writeMapEncodingRules.
public void writeMapEncodingRules(Map<String, MapRulType> types) throws IOException {
checkPeekState(MAP_INDEX_INIT);
ArrayList<MapRulType> out = new ArrayList<MapRulType>();
int highestTargetId = types.size();
// 1. prepare map rule type to write
for (MapRulType t : types.values()) {
if (t.getFreq() == 0 || !t.isMap()) {
t.setTargetId(highestTargetId++);
} else {
out.add(t);
}
}
// 2. sort by frequency and assign ids
Collections.sort(out, new Comparator<MapRulType>() {
@Override
public int compare(MapRulType o1, MapRulType o2) {
return o2.getFreq() - o1.getFreq();
}
});
for (int i = 0; i < out.size(); i++) {
MapEncodingRule.Builder builder = OsmandOdb.OsmAndMapIndex.MapEncodingRule.newBuilder();
MapRulType rule = out.get(i);
rule.setTargetId(i + 1);
builder.setTag(rule.getTag());
if (rule.getValue() != null) {
builder.setValue(rule.getValue());
}
builder.setMinZoom(rule.getMinzoom());
if (rule.isAdditional()) {
builder.setType(1);
} else if (rule.isText()) {
builder.setType(2);
}
MapEncodingRule rulet = builder.build();
codedOutStream.writeMessage(OsmandOdb.OsmAndMapIndex.RULES_FIELD_NUMBER, rulet);
}
}
Aggregations