Commit a667db63 authored by xuebingbing's avatar xuebingbing

1 新增指定pcd 导出fields的功能(兼容旧数据格式);

2 优化命令行使用信息
parent d9354fc5
...@@ -62,18 +62,22 @@ pdal::Dimension::Type GetLasDimDataType(const pcl::PCLPointField& field) ...@@ -62,18 +62,22 @@ pdal::Dimension::Type GetLasDimDataType(const pcl::PCLPointField& field)
} }
} }
std::unordered_map<std::string, pdal::Dimension::Id> GetLasdimidFromPcdFields(const std::vector<::pcl::PCLPointField>& pcdfields, pdal::PointLayoutPtr layerout) std::unordered_map<std::string, pdal::Dimension::Id> GetLasdimidFromPcdFields(const std::vector<::pcl::PCLPointField>& pcdfields, const jfhd::convert::Pcd2LasInfo& info, pdal::PointLayoutPtr layerout)
{ {
std::unordered_map<std::string, pdal::Dimension::Id> dict; std::unordered_map<std::string, pdal::Dimension::Id> dict;
for (auto field : pcdfields) for (auto& field : pcdfields)
{ {
if (0 == field.name.compare("_")) if (0 == info.fieldnames.count(field.name))
{
std::cout << "skip:" << field.name << std::endl;
continue; continue;
}
auto dimdatatype = GetLasDimDataType(field); auto dimdatatype = GetLasDimDataType(field);
if (pdal::Dimension::Type::None == dimdatatype) if (pdal::Dimension::Type::None == dimdatatype)
{ {
// TODO:: // TODO::
std::cout << "skip:" << field.name << std::endl;
continue; continue;
} }
...@@ -87,6 +91,8 @@ std::unordered_map<std::string, pdal::Dimension::Id> GetLasdimidFromPcdFields(co ...@@ -87,6 +91,8 @@ std::unordered_map<std::string, pdal::Dimension::Id> GetLasdimidFromPcdFields(co
dim = layerout->assignDim(field.name, dimdatatype); dim = layerout->assignDim(field.name, dimdatatype);
} }
std::cout << "export: " << field.name << "->" << layerout->dimName(dim) << std::endl;
dict.emplace(std::make_pair(field.name, dim)); dict.emplace(std::make_pair(field.name, dim));
} }
...@@ -210,7 +216,7 @@ namespace jfhd { ...@@ -210,7 +216,7 @@ namespace jfhd {
pdal::PointTable table; pdal::PointTable table;
auto layerout = table.layout(); auto layerout = table.layout();
std::unordered_map<std::string, pdal::Dimension::Id> std::unordered_map<std::string, pdal::Dimension::Id>
dict_pclfieldname_lasid = GetLasdimidFromPcdFields(pcloud.fields, table.layout()); dict_pclfieldname_lasid = GetLasdimidFromPcdFields(pcloud.fields, info, table.layout());
pdal::PointViewPtr view(new pdal::PointView(table)); pdal::PointViewPtr view(new pdal::PointView(table));
std::uint64_t width = pcloud.width; std::uint64_t width = pcloud.width;
......
#ifndef JF_HD_CONVERT_SWITH_H_ #ifndef JF_HD_CONVERT_SWITH_H_
#define JF_HD_CONVERT_SWITH_H_ #define JF_HD_CONVERT_SWITH_H_
#include <string> #include <string>
#include <set>
#include "export.h" #include "export.h"
namespace jfhd { namespace jfhd {
...@@ -8,9 +9,13 @@ namespace jfhd { ...@@ -8,9 +9,13 @@ namespace jfhd {
struct CONVERT_API Pcd2LasInfo struct CONVERT_API Pcd2LasInfo
{ {
// pcd x(y,z) + (offset x(y,z) = las x(y,z)
double offsetx = 0.0; double offsetx = 0.0;
double offsety = 0.0; double offsety = 0.0;
double offsetz = 0.0; double offsetz = 0.0;
// pcd 存在的fieldname 转换到las中, 为空时全部转换,不用指定x,y,z 字段, 区分大小写
std::set<std::string> fieldnames = {};
}; };
class CONVERT_API Convertor class CONVERT_API Convertor
...@@ -19,6 +24,15 @@ namespace jfhd { ...@@ -19,6 +24,15 @@ namespace jfhd {
Convertor(); Convertor();
~Convertor(); ~Convertor();
/**
* @brief pcd 转 las文件
* @param pcdfilepath 输入文件
* @param lasfilepath 输出文件
* @param info x,y,z
* @param fieldnames
* @param errormsg
* @return
*/
static bool Pcd2Las(const std::string& pcdfilepath, const std::string& lasfilepath, const Pcd2LasInfo& info, std::string* errormsg); static bool Pcd2Las(const std::string& pcdfilepath, const std::string& lasfilepath, const Pcd2LasInfo& info, std::string* errormsg);
}; };
} }
......
This diff is collapsed.
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