25namespace localization {
27namespace pyramid_map {
44 boost::property_tree::ptree config;
47 boost::property_tree::write_xml(file_path, config);
48 AINFO <<
"Saved the map configuration to: " << file_path;
55 boost::property_tree::ptree config;
56 boost::property_tree::read_xml(file_path, config);
60 AINFO <<
"Loaded the map configuration from: " << file_path;
76 config->put(
"map.map_runtime.map_ground_height_offset",
83 config->add(
"map.map_record.datasets.dataset",
map_datasets_[i]);
87 std::map<std::string, std::string>::const_iterator iter;
89 boost::property_tree::ptree child;
90 child.put(
"path", iter->first);
91 child.put(
"md5", iter->second);
92 config->add_child(
"map.check_info.nodes.node", child);
103 auto map_version = config.get_optional<std::string>(
"map.map_config.version");
107 auto coordinate_type =
108 config.get_optional<std::string>(
"map.map_config.coordinate_type");
109 if (coordinate_type) {
112 auto map_node_size_x =
113 config.get_optional<
unsigned int>(
"map.map_config.node_size.x");
114 if (map_node_size_x) {
118 auto map_node_size_y =
119 config.get_optional<
unsigned int>(
"map.map_config.node_size.y");
120 if (map_node_size_y) {
124 auto tmp_min_x = config.get_optional<
double>(
"map.map_config.range.min_x");
126 min_x = tmp_min_x.get();
129 auto tmp_min_y = config.get_optional<
double>(
"map.map_config.range.min_y");
131 min_y = tmp_min_y.get();
134 auto tmp_max_x = config.get_optional<
double>(
"map.map_config.range.max_x");
136 max_x = tmp_max_x.get();
139 auto tmp_max_y = config.get_optional<
double>(
"map.map_config.range.max_y");
141 max_y = tmp_max_y.get();
144 auto map_ground_height_offset =
145 config.get_optional<
float>(
"map.map_runtime.map_ground_height_offset");
146 if (map_ground_height_offset) {
149 auto map_is_compression =
150 config.get_optional<
bool>(
"map.map_config.compression");
151 if (map_is_compression) {
155 auto resolutions = config.get_child_optional(
"map.map_config.resolutions");
157 std::for_each(resolutions->begin(), resolutions->end(),
158 [
this](
const boost::property_tree::ptree::value_type &v) {
159 map_resolutions_.push_back(
160 static_cast<float>(atof(v.second.data().c_str())));
161 AINFO <<
"Resolution: " << v.second.data();
167 auto datasets = config.get_child_optional(
"map.map_record.datasets");
169 for (
const boost::property_tree::ptree::value_type &v : *datasets) {
171 AINFO <<
"Dataset: " << v.second.data();
176 auto nodes = config.get_child_optional(
"map.check_info.nodes");
178 for (
const boost::property_tree::ptree::value_type &v : *nodes) {
179 const boost::property_tree::ptree &child = v.second;
180 auto path = child.get_optional<std::string>(
"path");
181 auto md5 = child.get_optional<std::string>(
"md5");
183 AERROR <<
"Lack path or md5.";
203 double max_resolutions =
248 const std::map<std::string, std::string> &node_md5_map) {
253 const std::string &md5) {
T GetMaxY() const
Get the max y of the rectangle.
T GetMaxX() const
Get the max x of the rectangle.
T GetMinX() const
Get the min x of the rectangle.
T GetMinY() const
Get the min y of the rectangle.
std::vector< std::string > map_datasets_
The datasets that contributed to the map.
bool Save(const std::string &file_path)
Save the map option to a XML file.
std::string map_folder_path_
The map folder path.
unsigned int map_node_size_y_
The map node size in pixels.
void SetMapNodeSize(unsigned int size_x, unsigned int size_y)
Set map_node_size.
virtual bool CreateXml(boost::property_tree::ptree *config) const
Create the XML structure.
std::vector< float > map_resolutions_
The pixel resolutions in the map in meters.
std::string coordinate_type_
Rect2D< double > map_range_
The minimum and maximum UTM range in the map.
virtual bool LoadXml(const boost::property_tree::ptree &config)
Load the map options from a XML structure.
void AddNodeMd5(const std::string &node_path, const std::string &md5)
Add a node md5 pair.
bool Load(const std::string &file_path)
Load the map option from a XML file.
void SetMultiResolutions()
Set multi resolutions.
MapVersion GetMapVersion() const
Get map version.
virtual ~BaseMapConfig()
The deconstructor.
float map_ground_height_offset_
Velodyne's height to the ground.
bool map_is_compression_
Enable the compression.
void SetNodeMd5Map(const std::map< std::string, std::string > &node_md5_map)
Set node_md5_map.
void SetGroundHeightOffset(float map_ground_height_offset)
Set map_ground_height_offset.
BaseMapConfig(const std::string &map_version="0.1")
The constructor gives the default map settings.
unsigned int map_node_size_x_
The map node size in pixels.
std::map< std::string, std::string > node_md5_map_
The map structure to store map node file name and its md5.
void ResizeMapRange()
Resize map range by range and resolutions.
std::string map_version_
The version of map.
void SetSingleResolutions(float resolution=0.125)
Set single resolutions.
void SetMapVersion(const std::string &map_version)
Set map_version.
void SetIsCompression(bool map_is_compression)
Set map_is_compression.