Commit 3e1296be authored by xuebingbing's avatar xuebingbing

1 新增 pcd2las.stationfiles 模式,指定jf,jd站心文件,输入pcd和输出las文件

parent cad1c6e4
...@@ -9,4 +9,5 @@ IF(MSVC) ...@@ -9,4 +9,5 @@ IF(MSVC)
# ADD_DEFINITIONS(-DNOMINMAX) # ADD_DEFINITIONS(-DNOMINMAX)
ENDIF(MSVC) ENDIF(MSVC)
add_subdirectory(src)
\ No newline at end of file add_subdirectory(src)
...@@ -4,5 +4,5 @@ docker build --add-host --add-host=codeload.github.com:140.82.114.9 --add-host=g ...@@ -4,5 +4,5 @@ docker build --add-host --add-host=codeload.github.com:140.82.114.9 --add-host=g
#docker run -dit --privileged -v /home:/masterhome --name xuebb-test1221 --add-host --add-host=codeload.github.com:140.82.114.9 --add-host=github.com:140.82.113.4 --add-host=github.global.ssl.fastly.net:199.232.69.194 --add-host=s3.amazonaws.com:52.216.141.6 --add-host=github-cloud.s3.amazonaws.com:52.216.128.147 f8894edf0a24 /bin/bash #docker run -dit --privileged -v /home:/masterhome --name xuebb-test1221 --add-host --add-host=codeload.github.com:140.82.114.9 --add-host=github.com:140.82.113.4 --add-host=github.global.ssl.fastly.net:199.232.69.194 --add-host=s3.amazonaws.com:52.216.141.6 --add-host=github-cloud.s3.amazonaws.com:52.216.128.147 f8894edf0a24 /bin/bash
docker run -dit --privileged -v /home:/masterhome --name xuebb-test0103 --add-host --add-host=codeload.github.com:140.82.114.9 --add-host=github.com:140.82.113.4 --add-host=github.global.ssl.fastly.net:199.232.69.194 --add-host=s3.amazonaws.com:52.216.141.6 --add-host=github-cloud.s3.amazonaws.com:52.216.128.147 dc9e44d57d31 /bin/bash docker run -dit --privileged -v /home:/masterhome --name xuebb-test0103 --add-host --add-host=codeload.github.com:140.82.114.9 --add-host=github.com:140.82.113.4 --add-host=github.global.ssl.fastly.net:199.232.69.194 --add-host=s3.amazonaws.com:52.216.141.6 --add-host=github-cloud.s3.amazonaws.com:52.216.128.147 2241b3437218 /bin/bash
...@@ -33,6 +33,9 @@ int pcd2las(const cxxopts::ParseResult& argsresult); ...@@ -33,6 +33,9 @@ int pcd2las(const cxxopts::ParseResult& argsresult);
int pcd2lasauto(const cxxopts::ParseResult& argsresult); int pcd2lasauto(const cxxopts::ParseResult& argsresult);
int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult);
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
auto res = parse(argc, argv); auto res = parse(argc, argv);
...@@ -50,20 +53,27 @@ int main(int argc, char* argv[]) ...@@ -50,20 +53,27 @@ int main(int argc, char* argv[])
} }
} }
if (modes.count("pcd2las.auto")) if (modes.count("pcd2las.auto") > 0)
{ {
std::cout << ">>>begin pcd2las.auto --------------------------------------------------" << std::endl; std::cout << ">>>begin pcd2las.auto --------------------------------------------------" << std::endl;
pcd2lasauto(res); pcd2lasauto(res);
std::cout << ">>>end pcd2las.auto --------------------------------------------------" << std::endl; std::cout << ">>>end pcd2las.auto --------------------------------------------------" << std::endl;
} }
if (modes.count("pcs2las")) if (modes.count("pcs2las") > 0)
{ {
std::cout << ">>>begin pcd2las--------------------------------------------------" << std::endl; std::cout << ">>>begin pcd2las--------------------------------------------------" << std::endl;
pcd2las(res); pcd2las(res);
std::cout << ">>>end pcd2las--------------------------------------------------" << std::endl; std::cout << ">>>end pcd2las--------------------------------------------------" << std::endl;
} }
if (modes.count("pcd2las.stationfiles") > 0)
{
std::cout << ">>>begin pcd2las.stationfiles--------------------------------------------------" << std::endl;
pcd2lasByStationFiles(res);
std::cout << ">>>end pcd2las.stationfiles--------------------------------------------------" << std::endl;
}
return true; return true;
...@@ -112,7 +122,8 @@ cxxopts::ParseResult parse(int argc, char* argv[]) ...@@ -112,7 +122,8 @@ cxxopts::ParseResult parse(int argc, char* argv[])
options options
.allow_unrecognised_options() .allow_unrecognised_options()
.add_options() .add_options()
("m,mode", "pcd2las,pcd2las.auto", cxxopts::value<std::string>()->default_value("pcd2las.auto")) ("m,mode", "pcd2las : must args --workdir; pcd2las.auto: must args --pcdfile,--lasfile; pcd2las.stationfiles : must args --pcdfile,--lasfile,--jf_station_file, --jd_station_file",
cxxopts::value<std::string>()->default_value("pcd2las.stationfiles"))
("h,help", "Print help") ("h,help", "Print help")
#ifdef CXXOPTS_USE_UNICODE #ifdef CXXOPTS_USE_UNICODE
("unicode", u8"A help option with non-ascii: à. Here the size of the" ("unicode", u8"A help option with non-ascii: à. Here the size of the"
...@@ -120,19 +131,45 @@ cxxopts::ParseResult parse(int argc, char* argv[]) ...@@ -120,19 +131,45 @@ cxxopts::ParseResult parse(int argc, char* argv[])
#endif #endif
; ;
options.add_options("pcd2las.auto") //options
("workdir", "自动化的任务根目录", cxxopts::value<std::string>()); // .allow_unrecognised_options()
// .add_options()
options.add_options("pcd2las") // ("m,mode", "test"
// "pcd2las : must args --workdir\n"
// "pcd2las.auto : must args --pcdfile,--lasfile\n"
// "pcd2las.stationfiles : must args --pcdfile,--lasfile,--jf_station_file, --jd_station_file\n",
// cxxopts::value<std::string>()->default_value("pcd2las.stationfiles"))
// ("h,help", "Print help")
// #ifdef CXXOPTS_USE_UNICODE
// ("unicode", u8"A help option with non-ascii: à. Here the size of the"
// " string should be correct")
// #endif
// ;
options.add_options("options")
("workdir", "自动化的任务根目录", cxxopts::value<std::string>())
("pcdfile", "输入pcd文件路径", cxxopts::value<std::string>()) ("pcdfile", "输入pcd文件路径", cxxopts::value<std::string>())
("lasfile", "输出las文件路径", cxxopts::value<std::string>()) ("lasfile", "输出las文件路径", cxxopts::value<std::string>())
("offsetxyz", "A list of doubles", cxxopts::value<std::vector<double>>()->default_value("0.0,0.0,0.0")); ("offsetxyz", "A list of doubles", cxxopts::value<std::vector<double>>()->default_value("0.0,0.0,0.0"))
("jf_station_file", "JF 站心定义文件,必须包含 E0_PROJECT:* N0_PROJECT:* H0_PROJECT:* 三对UTM 站心(偏移)信息", cxxopts::value<std::string>())
("jd_station_file", "JD 站心和校正,必须包含E0_UTM_JD:* N0_UTM_JD:* H0_UTM_JD:* 三对UTM 站心(偏移)信息, 可包含E_OFFSET:* N_OFFSET:* H_OFFSET:* 的校正信息", cxxopts::value<std::string>());
//options.add_options("pcd2las")
//("pcdfile", "输入pcd文件路径", cxxopts::value<std::string>())
//("lasfile", "输出las文件路径", cxxopts::value<std::string>())
//("offsetxyz", "A list of doubles", cxxopts::value<std::vector<double>>()->default_value("0.0,0.0,0.0"));
//options.add_options("pcd2las.stationfiles")
//("pcdfile", "输入pcd文件路径", cxxopts::value<std::string>())
//("lasfile", "输出las文件路径", cxxopts::value<std::string>())
//("jf_station_file", "JF 站心定义文件,必须包含 E0_PROJECT:* N0_PROJECT:* H0_PROJECT:* 三对UTM 站心(偏移)信息", cxxopts::value<std::string>())
//("jd_station_file", "JD 站心和校正,必须包含E0_UTM_JD:* N0_UTM_JD:* H0_UTM_JD:* 三对UTM 站心(偏移)信息, 可包含E_OFFSET:* N_OFFSET:* H_OFFSET:* 的校正信息", cxxopts::value<std::string>());
auto result = options.parse(argc, argv); auto result = options.parse(argc, argv);
if (0 == result.arguments().size() || result.count("help")) if (0 == result.arguments().size() || result.count("help"))
{ {
std::cout << options.help({ "" , "pcd2las.auto", "pcd2las" }) << std::endl; std::cout << options.help({ "" , "options" }) << std::endl;
exit(0); exit(0);
} }
...@@ -433,13 +470,13 @@ bool ReadJdStationFile(const std::string& filepath, str_dict* jddict) ...@@ -433,13 +470,13 @@ bool ReadJdStationFile(const std::string& filepath, str_dict* jddict)
}; };
if (!checkfunc("E_OFFSET")) if (!checkfunc("E_OFFSET"))
return false; jddict->emplace("E_OFFSET", "0.0");
if (!checkfunc("N_OFFSET")) if (!checkfunc("N_OFFSET"))
return false; jddict->emplace("N_OFFSET", "0.0");
if (!checkfunc("H_OFFSET")) if (!checkfunc("H_OFFSET"))
return false; jddict->emplace("H_OFFSET", "0.0");
if (!checkfunc("E0_UTM_JD")) if (!checkfunc("E0_UTM_JD"))
return false; return false;
...@@ -453,6 +490,120 @@ bool ReadJdStationFile(const std::string& filepath, str_dict* jddict) ...@@ -453,6 +490,120 @@ bool ReadJdStationFile(const std::string& filepath, str_dict* jddict)
return true; return true;
} }
int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
{
using boost::filesystem::path;
using boost::filesystem::initial_path;
using boost::filesystem::system_complete;
using boost::filesystem::exists;
using boost::filesystem::is_regular_file;
constexpr const const char* currentmode = "pcd2las.stationfiles";
//("pcdfile", "输入pcd文件路径", cxxopts::value<std::string>())
//("lasfile", "输出las文件路径", cxxopts::value<std::string>())
//("jf_station_file", "JF 站心定义文件,必须包含 E0_PROJECT:* N0_PROJECT:* H0_PROJECT:* 三对UTM 站心(偏移)信息", cxxopts::value<std::string>())
//("jd_station_file", "JD 站心和校正,必须包含E0_UTM_JD:* N0_UTM_JD:* H0_UTM_JD:* 三对UTM 站心(偏移)信息, 可包含E_OFFSET:* N_OFFSET:* H_OFFSET:* 的校正信息", cxxopts::value<std::string>());
boost::system::error_code sys_err_code;
if (argsresult.count("jf_station_file") < 0)
{
std::cout << "ERROR: " << currentmode << " 未指定觉非站心文件" << std::endl;
return -1;
}
std::string temp = argsresult["jf_station_file"].as<std::string>();
// 查找station_jf.txt文件
path testdir(initial_path());
//workdir = system_complete(path(workdirpath, portable_name));
testdir = system_complete(path(temp));
//workdir = system_complete(path(workdirpath));
path jf_stationfilepath(temp.begin(), temp.end());// = initial_path();
jf_stationfilepath = system_complete(jf_stationfilepath, sys_err_code);
//auto jf_stationfilepath = system_complete(path(temp), sys_err_code);
if (sys_err_code.failed() || !exists(jf_stationfilepath) || !is_regular_file(jf_stationfilepath))
{
std::cout << "ERROR:" << currentmode << " 找不到觉非站心文件:" << jf_stationfilepath.string() << " DETAIL:" << sys_err_code.message() << std::endl;
return -1;
}
if (argsresult.count("jd_station_file") < 0)
{
std::cout << "ERROR: " << currentmode << " 未指定京东站心文件" << std::endl;
return -1;
}
temp = argsresult["jd_station_file"].as<std::string>();
auto jd_stationfilepath = system_complete(path(temp), sys_err_code);
if (sys_err_code.failed() || !exists(jd_stationfilepath) || !is_regular_file(jd_stationfilepath))
{
std::cout << "ERROR:" << currentmode << " 找不到京东站心文件:" << jf_stationfilepath.string() << " DETAIL:" << sys_err_code.message() << std::endl;
return -1;
}
temp = argsresult["pcdfile"].as<std::string>();
if (argsresult.count("pcdfile") < 0)
{
std::cout << "ERROR: " << currentmode << " 未指定输入pcd文件" << std::endl;
return -1;
}
//path pcd_filepath(temp);
auto pcd_filepath = system_complete(path(temp), sys_err_code);
if (sys_err_code.failed() || !exists(pcd_filepath) || !is_regular_file(pcd_filepath))
{
std::cout << "ERROR:" << currentmode << " 指定pcd文件错误:" << jf_stationfilepath.string() << " DETAIL:" << sys_err_code.message() << std::endl;
return -1;
}
temp = argsresult["lasfile"].as<std::string>();
if (argsresult.count("lasfile") < 0)
{
std::cout << "ERROR: " << currentmode << " 未指定输入las文件" << std::endl;
return -1;
}
auto las_filepath = system_complete(path(temp), sys_err_code);
if (!sys_err_code.failed() && exists(las_filepath) && is_regular_file(las_filepath))
{
std::cout << "INFO:" << currentmode << " 指定输出las文件已存在,将覆盖原文件 " << las_filepath.string() << std::endl;
//return -1;
}
if (!exists(las_filepath.parent_path()))
{
std::cout << "INFO:" << currentmode << " 创建las输出文件夹=" << las_filepath.parent_path().string() << std::endl;
boost::filesystem::create_directories(las_filepath.parent_path());
}
// 读取taskid_station_jf.txt,taskid_station_jd.txt
str_dict jf_station_dict, jd_station_dict;
if (!ReadJfStationFile(jf_stationfilepath.string(), &jf_station_dict))
return -1;
if (!ReadJdStationFile(jd_stationfilepath.string(), &jd_station_dict))
return -1;
jfhd::convert::Pcd2LasInfo convert_info;
if (!CalcConvertInfo(jf_station_dict, jd_station_dict, &convert_info))
return -1;
std::cout << "offsetx = " << convert_info.offsetx << std::endl;
std::cout << "offsety = " << convert_info.offsety << std::endl;
std::cout << "offsetz = " << convert_info.offsetz << std::endl;
std::string errormsg;
if (!jfhd::convert::Convertor::Pcd2Las(pcd_filepath.string(), las_filepath.string(), convert_info, &errormsg))
{
std::cout << "ERROR: failed" << pcd_filepath.string() << ">>" << las_filepath.string() << std::endl;
}
else
{
std::cout << "INFO: successed " << pcd_filepath.string() << ">>" << las_filepath.string() << std::endl;
}
return 0;
}
//#include <corecrt_io.h> //#include <corecrt_io.h>
//#include <pcl/io/pcd_io.h> //#include <pcl/io/pcd_io.h>
//#include <pcl/point_types.h> //#include <pcl/point_types.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment