shench3
2026-03-03 867d735635873ccef7d6e7b48cc6f0df25b9ac3d
feat: 区域版本文件生成
2个文件已修改
33 ■■■■■ 已修改文件
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/AdcOssHandleServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/MapAreaVersionProtoWriter.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/AdcOssHandleServiceImpl.java
@@ -13,7 +13,6 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.List;
/**
@@ -44,12 +43,8 @@
        String objectKey = robotaxiOssService.uploadOddLayerFile(fbsBytes, binFileName, areaCode, vehicleUuid);
        try {
            byte[] pbBytes = MapAreaVersionProtoWriter.toByteArray(version, fbsBytes.length);
            robotaxiOssService.uploadOddLayerFile(pbBytes, "xngp_area_version.pb", areaCode, vehicleUuid);
        } catch (IOException e) {
            throw new IllegalStateException("Failed to build or upload xngp_area_version.pb", e);
        }
        byte[] pbBytes = MapAreaVersionProtoWriter.toByteArray(version, fbsBytes.length);
        robotaxiOssService.uploadOddLayerFile(pbBytes, "xngp_area_version.pb", areaCode, vehicleUuid);
        log.debug("AdcOssHandle uploaded ODD layer file, areaId={}, areaCode={}, objectKey={}", areaId, areaCode, objectKey);
        return objectKey;
xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/utils/MapAreaVersionProtoWriter.java
@@ -1,11 +1,9 @@
package com.xiaopeng.map.utils;
import com.google.protobuf.CodedOutputStream;
import java.io.IOException;
/**
 * 将 MapAreaVersion 序列化为与 map_area_version.proto 兼容的 Protobuf 二进制格式。
 * 将 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 {
@@ -13,20 +11,14 @@
    }
    /**
     * 生成 MapAreaVersion 的 protobuf 二进制
     * 生成 MapAreaVersion 的 text proto 格式,与 C++ DebugString() 输出一致。
     *
     * @param version    Unix 秒级时间戳
     * @param fileLength bin 文件字节长度
     * @return protobuf 二进制
     * @return text proto 字节(平台默认编码)
     */
    public static byte[] toByteArray(int version, int fileLength) throws IOException {
        int size = CodedOutputStream.computeUInt32Size(1, version)
                + CodedOutputStream.computeUInt32Size(2, fileLength);
        byte[] buf = new byte[size];
        CodedOutputStream cos = CodedOutputStream.newInstance(buf);
        cos.writeUInt32(1, version);
        cos.writeUInt32(2, fileLength);
        cos.checkNoSpaceLeft();
        return buf;
    public static byte[] toByteArray(int version, int fileLength) {
        String text = "version: " + version + "\nfile_length: " + fileLength + "\n";
        return text.getBytes();
    }
}