| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | 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; |
| | |
| | | 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 { |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成 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(); |
| | | } |
| | | } |