Search in sources :

Example 1 with StringTable

use of net.osmand.binary.OsmandOdb.StringTable in project OsmAnd-tools by osmandapp.

the class BinaryMapIndexWriter method writeRouteDataBlock.

public void writeRouteDataBlock(RouteDataBlock.Builder builder, Map<String, Integer> stringTable, BinaryFileReference ref) throws IOException {
    checkPeekState(ROUTE_INDEX_INIT);
    if (stringTable != null && stringTable.size() > 0) {
        StringTable.Builder bs = OsmandOdb.StringTable.newBuilder();
        for (String s : stringTable.keySet()) {
            bs.addS(s);
        }
        StringTable st = bs.build();
        builder.setStringTable(st);
        int size = st.getSerializedSize();
        ROUTE_STRING_DATA_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapDataBlock.STRINGTABLE_FIELD_NUMBER) + CodedOutputStream.computeRawVarint32Size(size) + size;
    }
    codedOutStream.writeTag(OsmAndMapIndex.MapRootLevel.BLOCKS_FIELD_NUMBER, FieldType.MESSAGE.getWireType());
    codedOutStream.flush();
    ref.writeReference(raf, getFilePointer());
    RouteDataBlock block = builder.build();
    ROUTE_DATA_SIZE += block.getSerializedSize();
    codedOutStream.writeMessageNoTag(block);
}
Also used : StringTable(net.osmand.binary.OsmandOdb.StringTable) RouteDataBlock(net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock) ByteString(com.google.protobuf.ByteString)

Example 2 with StringTable

use of net.osmand.binary.OsmandOdb.StringTable in project OsmAnd-tools by osmandapp.

the class BinaryMapIndexWriter method writeTransportStringTable.

public void writeTransportStringTable(Map<String, Integer> stringTable) throws IOException {
    checkPeekState(TRANSPORT_INDEX_INIT);
    // expect linked hash map
    int i = 0;
    OsmandOdb.StringTable.Builder st = OsmandOdb.StringTable.newBuilder();
    for (String s : stringTable.keySet()) {
        if (stringTable.get(s) != i++) {
            throw new IllegalStateException();
        }
        st.addS(s);
    }
    codedOutStream.writeMessage(OsmAndTransportIndex.STRINGTABLE_FIELD_NUMBER, st.build());
}
Also used : StringTable(net.osmand.binary.OsmandOdb.StringTable) ByteString(com.google.protobuf.ByteString)

Example 3 with StringTable

use of net.osmand.binary.OsmandOdb.StringTable in project OsmAnd-tools by osmandapp.

the class BinaryMapIndexWriter method writeMapDataBlock.

public void writeMapDataBlock(MapDataBlock.Builder builder, Map<String, Integer> stringTable, BinaryFileReference ref) throws IOException {
    checkPeekState(MAP_ROOT_LEVEL_INIT);
    StringTable.Builder bs = OsmandOdb.StringTable.newBuilder();
    if (stringTable != null) {
        for (String s : stringTable.keySet()) {
            bs.addS(s);
        }
    }
    StringTable st = bs.build();
    builder.setStringTable(st);
    int size = st.getSerializedSize();
    STRING_TABLE_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapDataBlock.STRINGTABLE_FIELD_NUMBER) + CodedOutputStream.computeRawVarint32Size(size) + size;
    codedOutStream.writeTag(OsmAndMapIndex.MapRootLevel.BLOCKS_FIELD_NUMBER, FieldType.MESSAGE.getWireType());
    codedOutStream.flush();
    ref.writeReference(raf, getFilePointer());
    MapDataBlock block = builder.build();
    MAP_DATA_SIZE += block.getSerializedSize();
    codedOutStream.writeMessageNoTag(block);
}
Also used : StringTable(net.osmand.binary.OsmandOdb.StringTable) MapDataBlock(net.osmand.binary.OsmandOdb.MapDataBlock) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)3 StringTable (net.osmand.binary.OsmandOdb.StringTable)3 MapDataBlock (net.osmand.binary.OsmandOdb.MapDataBlock)1 RouteDataBlock (net.osmand.binary.OsmandOdb.OsmAndRoutingIndex.RouteDataBlock)1