use of net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule in project OsmAnd-tools by osmandapp.
the class BinaryMapIndexWriter method writeRouteEncodingRules.
public void writeRouteEncodingRules(List<MapRouteType> types) throws IOException {
checkPeekState(ROUTE_INDEX_INIT);
ArrayList<MapRouteType> out = new ArrayList<MapRouteType>(types);
// 2. sort by frequency and assign ids
Collections.sort(out, new Comparator<MapRouteType>() {
@Override
public int compare(MapRouteType o1, MapRouteType o2) {
return o2.getFreq() - o1.getFreq();
}
});
for (int i = 0; i < out.size(); i++) {
RouteEncodingRule.Builder builder = OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule.newBuilder();
MapRouteType rule = out.get(i);
rule.setTargetId(i + 1);
builder.setTag(rule.getTag());
if (rule.getValue() != null) {
builder.setValue(rule.getValue());
} else {
builder.setValue("");
}
RouteEncodingRule rulet = builder.build();
codedOutStream.writeMessage(OsmandOdb.OsmAndRoutingIndex.RULES_FIELD_NUMBER, rulet);
}
}
use of net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule in project OsmAnd-tools by osmandapp.
the class BinaryMapIndexWriter method writeRouteRawEncodingRules.
public void writeRouteRawEncodingRules(List<BinaryMapRouteReaderAdapter.RouteTypeRule> types) throws IOException {
checkPeekState(ROUTE_INDEX_INIT);
for (int i = 1; i < types.size(); i++) {
RouteEncodingRule.Builder builder = OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule.newBuilder();
RouteTypeRule rule = types.get(i);
builder.setTag(rule.getTag());
if (rule.getValue() != null) {
builder.setValue(rule.getValue());
} else {
builder.setValue("");
}
RouteEncodingRule rulet = builder.build();
codedOutStream.writeMessage(OsmandOdb.OsmAndRoutingIndex.RULES_FIELD_NUMBER, rulet);
}
}
Aggregations