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)
}
}
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;
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;
}
auto dimdatatype = GetLasDimDataType(field);
if (pdal::Dimension::Type::None == dimdatatype)
{
// TODO::
std::cout << "skip:" << field.name << std::endl;
continue;
}
......@@ -87,6 +91,8 @@ std::unordered_map<std::string, pdal::Dimension::Id> GetLasdimidFromPcdFields(co
dim = layerout->assignDim(field.name, dimdatatype);
}
std::cout << "export: " << field.name << "->" << layerout->dimName(dim) << std::endl;
dict.emplace(std::make_pair(field.name, dim));
}
......@@ -210,7 +216,7 @@ namespace jfhd {
pdal::PointTable table;
auto layerout = table.layout();
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));
std::uint64_t width = pcloud.width;
......
#ifndef JF_HD_CONVERT_SWITH_H_
#define JF_HD_CONVERT_SWITH_H_
#include <string>
#include <set>
#include "export.h"
namespace jfhd {
......@@ -8,9 +9,13 @@ namespace jfhd {
struct CONVERT_API Pcd2LasInfo
{
// pcd x(y,z) + (offset x(y,z) = las x(y,z)
double offsetx = 0.0;
double offsety = 0.0;
double offsetz = 0.0;
// pcd 存在的fieldname 转换到las中, 为空时全部转换,不用指定x,y,z 字段, 区分大小写
std::set<std::string> fieldnames = {};
};
class CONVERT_API Convertor
......@@ -19,6 +24,15 @@ namespace jfhd {
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);
};
}
......
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