puzhibing
2026-03-13 d4f8d30d1c6e4397dbfbdbb759cc66132913dd53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.xiaopeng.map.utils;
 
/**
 * 将 MapAreaVersion 序列化为与 map_area_version.proto 兼容的 Protobuf 文本格式(text proto)。
 * 与 C++ xngp_area_fbs_convertor 的 DebugString() 输出一致,供 xngp_area_queryer 使用 TextFormat 解析。
 * 使用平台默认编码(非 UTF-8 强制指定),与 C++ 读取端编码保持一致。
 */
public final class MapAreaVersionProtoWriter {
 
    private MapAreaVersionProtoWriter() {
    }
 
    /**
     * 生成 MapAreaVersion 的 text proto 格式,与 C++ DebugString() 输出一致。
     *
     * @param version    Unix 秒级时间戳
     * @param fileLength bin 文件字节长度
     * @return text proto 字节(平台默认编码)
     */
    public static byte[] toByteArray(int version, int fileLength) {
        String text = "version: " + version + "\nfile_length: " + fileLength + "\n";
        return text.getBytes();
    }
}