12.2. How to Convert Binary (bin) Format Maps to Text (txt) Format?
What is the difference between binary format maps and text format maps? How can they be converted between each other?
Maintainer: daohu527@gmail.com
Version: 1.0.0
Date: 05/09/2024
Description:
12.2.1. Answer
Apollo high-definition maps are primarily implemented based on the protobuf protocol, which supports two file formats for storage: bin and txt.
Bin Format This is a compact file format, advantageous for significantly reducing file size, thus minimizing storage and transmission costs. However, because it is binary encoded, it cannot be directly read by text editors.
Txt Format This is a text-based storage method, allowing map data to be intuitively displayed in text form, making it easier for developers to view and debug. However, this format takes up more storage space and has relatively lower transmission efficiency.
In practical applications, to ensure efficient storage and transmission of map data, the Apollo system typically opts to use the bin format for saving and loading maps. The txt format serves mainly as an auxiliary means for debugging and viewing, facilitating developers in understanding and verifying map data.
12.2.1.1. Binary (bin) to Text (txt)
Install protoc
Install protoc, refer to Installing protoc.
Run the command
# modules/map/data/borregas_ave/base_map.bin (replace with the map you want to convert)
protoc --decode apollo.hdmap.Map modules/map/proto/map.proto < modules/map/data/borregas_ave/base_map.bin > base_map.txt
The converted map file
base_map.txtis saved in the current working directory.
12.2.1.2. Text (txt) to Binary (bin)
Install protoc
Same as above.
Run the command
# modules/map/data/demo/base_map.txt (replace with the map you want to convert)
protoc --encode apollo.hdmap.Map modules/map/proto/map.proto < modules/map/data/demo/base_map.txt > base_map.bin
The converted map file
base_map.binis saved in the current working directory.