17#include <boost/filesystem.hpp>
18#include <boost/program_options.hpp>
33namespace localization {
39 sscanf(map_folder.c_str(),
"/%03u/%05s/%02d/%08u/%08u", &index.
resolution_id_,
41 std::string zone = buf;
42 if (zone ==
"south") {
50 const std::string& dst_map_folder,
51 std::list<MapNodeIndex>* buf) {
52 std::string src_map_path = src_map_folder +
"/map";
53 std::string dst_map_path = dst_map_folder +
"/map";
54 boost::filesystem::path src_map_path_boost(src_map_path);
55 boost::filesystem::path dst_map_path_boost(dst_map_path);
57 if (!boost::filesystem::exists(dst_map_path)) {
58 boost::filesystem::create_directory(dst_map_path_boost);
64 boost::filesystem::recursive_directory_iterator end_iter;
65 boost::filesystem::recursive_directory_iterator iter(src_map_path_boost);
66 for (; iter != end_iter; ++iter) {
67 if (!boost::filesystem::is_directory(*iter)) {
68 if (iter->path().extension() ==
"") {
70 std::string tmp = iter->path().string();
71 tmp = tmp.substr(src_map_path.length(), tmp.length());
75 std::string tmp = iter->path().string();
76 tmp = tmp.substr(src_map_path.length(), tmp.length());
77 tmp = dst_map_path + tmp;
78 boost::filesystem::path p(tmp);
79 if (!boost::filesystem::exists(p)) {
80 boost::filesystem::create_directory(p);
92int main(
int argc,
char** argv) {
93 boost::program_options::options_description boost_desc(
"Allowed options");
94 boost_desc.add_options()(
"help",
"produce help message")(
95 "srcdir", boost::program_options::value<std::string>(),
96 "provide the data base dir")(
"dstdir",
97 boost::program_options::value<std::string>(),
98 "provide the lossy map destination dir");
100 boost::program_options::variables_map boost_args;
101 boost::program_options::store(
102 boost::program_options::parse_command_line(argc, argv, boost_desc),
104 boost::program_options::notify(boost_args);
106 if (boost_args.count(
"help") || !boost_args.count(
"srcdir") ||
107 !boost_args.count(
"dstdir")) {
112 const std::string src_path = boost_args[
"srcdir"].as<std::string>();
113 const std::string dst_path = boost_args[
"dstdir"].as<std::string>();
114 std::string src_map_folder = src_path +
"/";
118 lossless_map_node_pool.
Initial(&lossless_config);
124 AERROR <<
"Reflectance map folder is invalid!";
129 std::string dst_map_folder = dst_path +
"/lossy_map/";
130 if (!boost::filesystem::exists(dst_map_folder)) {
131 boost::filesystem::create_directory(dst_map_folder);
134 std::list<MapNodeIndex> buf;
137 AINFO <<
"index size: " << buf.size();
140 config_transform_lossy.
Load(src_map_folder +
"config.xml");
142 config_transform_lossy.
Save(dst_map_folder +
"config.xml");
144 AINFO <<
"lossy map directory structure has built.";
147 lossy_map_node_pool.
Initial(&config_transform_lossy);
148 PyramidMap lossy_map(&config_transform_lossy);
152 AINFO <<
"lossy_map config xml not exist";
156 auto itr = buf.begin();
157 for (; itr != buf.end(); ++itr, ++index) {
160 if (lossless_node ==
nullptr) {
161 AWARN <<
"index: " << index <<
" is a nullptr pointer!";
174 for (
int row = 0; row < rows; ++row) {
175 for (
int col = 0; col < cols; ++col) {
177 const float* intensity_var =
179 const unsigned int* count = lossless_matrix.
GetCountSafe(row, col);
182 const float* altitude_var =
184 const float* altitude_ground =
186 const unsigned int* ground_count =
203 if (altitude_ground) {
unsigned int m_
The map node ID at the northing direction.
unsigned int n_
The map node ID at the easting direction.
unsigned int resolution_id_
The ID of the resolution.
bool Save(const std::string &file_path)
Save the map option to a XML file.
unsigned int map_node_size_y_
The map node size in pixels.
bool Load(const std::string &file_path)
Load the map option from a XML file.
unsigned int map_node_size_x_
The map node size in pixels.
std::string map_version_
The version of map.
void Initial(const BaseMapConfig *map_config, bool is_fixed_size=true)
Initialize the pool.
const BaseMapMatrix & GetMapCellMatrix() const
Get map cell matrix.
void SetIsChanged(bool is)
Set if the map node data has changed.
bool SetMapFolderPath(const std::string folder_path)
Set the directory of the map.
BaseMapNode * GetMapNodeSafe(const MapNodeIndex &index)
Return the map node, if it's not in the cache, safely load it.
virtual void InitMapNodeCaches(int cacheL1_size, int cahceL2_size)
void AttachMapNodePool(BaseMapNodePool *p_map_node_pool)
Attach map node pointer.
const unsigned int * GetGroundCountSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get a ground count value by check.
const float * GetIntensityVarSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an intensity variance value by check.
const float * GetIntensitySafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an intensity value by check.
void SetGroundAltitudeSafe(float ground_altitude, unsigned int row, unsigned int col, unsigned int level=0)
Set an altitude ground value by check.
const float * GetAltitudeSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an altitude value by check.
void SetAltitudeSafe(float altitude, unsigned int row, unsigned int col, unsigned int level=0)
Set an altitude value by check.
void SetCountSafe(unsigned int count, unsigned int row, unsigned int col, unsigned int level=0)
Set a count value by check.
const unsigned int * GetCountSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get a count value by check.
void SetIntensityVarSafe(float intensity_var, unsigned int row, unsigned int col, unsigned int level=0)
Set an intensity variance value by check.
const float * GetAltitudeVarSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an altitude variance value by check.
const float * GetGroundAltitudeSafe(unsigned int row, unsigned int col, unsigned int level=0) const
Get an altitude ground value by check.
void SetGroundCountSafe(unsigned int ground_count, unsigned int row, unsigned int col, unsigned int level=0)
Set a ground count value by check.
void SetIntensitySafe(float intensity, unsigned int row, unsigned int col, unsigned int level=0)
Set an intensity value by check.
void SetAltitudeVarSafe(float altitude_var, unsigned int row, unsigned int col, unsigned int level=0)
Set an altitude variance value by check.
int main(int argc, char **argv)
bool GetAllMapIndex(const std::string &src_map_folder, const std::string &dst_map_folder, std::list< MapNodeIndex > *buf)
MapNodeIndex GetMapIndexFromMapFolder(const std::string &map_folder)