Search in sources :

Example 1 with RouteEncodingRule

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);
    }
}
Also used : TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) TByteArrayList(gnu.trove.list.array.TByteArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList) RouteEncodingRule(net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule) MapRouteType(net.osmand.osm.MapRoutingTypes.MapRouteType)

Example 2 with RouteEncodingRule

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);
    }
}
Also used : RouteTypeRule(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule) RouteEncodingRule(net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule)

Aggregations

RouteEncodingRule (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteEncodingRule)2 TByteArrayList (gnu.trove.list.array.TByteArrayList)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 TLongArrayList (gnu.trove.list.array.TLongArrayList)1 ArrayList (java.util.ArrayList)1 RouteTypeRule (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule)1 MapRouteType (net.osmand.osm.MapRoutingTypes.MapRouteType)1