Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
fmt_converter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xuebingbing
fmt_converter
Commits
a667db63
Commit
a667db63
authored
Apr 27, 2021
by
xuebingbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1 新增指定pcd 导出fields的功能(兼容旧数据格式);
2 优化命令行使用信息
parent
d9354fc5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
609 deletions
+63
-609
convertor.cpp
src/jfhdconvert/convertor.cpp
+10
-4
convertor.h
src/jfhdconvert/convertor.h
+14
-0
main.cpp
src/jfhdconvertor/main.cpp
+39
-605
No files found.
src/jfhdconvert/convertor.cpp
View file @
a667db63
...
@@ -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
;
...
...
src/jfhdconvert/convertor.h
View file @
a667db63
#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
);
};
};
}
}
...
...
src/jfhdconvertor/main.cpp
View file @
a667db63
...
@@ -18,13 +18,6 @@
...
@@ -18,13 +18,6 @@
#include <boost/format.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string.hpp>
//void TestPcdreader();
//
//void TestPdalReadLas();
//
//void TestPdalWriteLas();
//
//void TestPcd2Las();
#include "3parts/cxxopts.hpp"
#include "3parts/cxxopts.hpp"
cxxopts
::
ParseResult
parse
(
int
argc
,
char
*
argv
[]);
cxxopts
::
ParseResult
parse
(
int
argc
,
char
*
argv
[]);
...
@@ -66,10 +59,9 @@ int main(int argc, char* argv[])
...
@@ -66,10 +59,9 @@ int main(int argc, char* argv[])
//if (modes.count("pcd2las.stationfiles") > 0)
//if (modes.count("pcd2las.stationfiles") > 0)
//{
//{
std
::
cout
<<
">>>begin pcd2las.stationfiles--------------------------------------------------"
<<
std
::
endl
;
std
::
cout
<<
">>>begin pcd2las.stationfiles--------------------------------------------------"
<<
std
::
endl
;
pcd2lasByStationFiles
(
res
);
pcd2lasByStationFiles
(
res
);
std
::
cout
<<
">>>end pcd2las.stationfiles--------------------------------------------------"
<<
std
::
endl
;
std
::
cout
<<
">>>end pcd2las.stationfiles--------------------------------------------------"
<<
std
::
endl
;
//}
return
true
;
return
true
;
...
@@ -119,48 +111,21 @@ cxxopts::ParseResult parse(int argc, char* argv[])
...
@@ -119,48 +111,21 @@ cxxopts::ParseResult parse(int argc, char* argv[])
options
options
.
allow_unrecognised_options
()
.
allow_unrecognised_options
()
.
add_options
()
.
add_options
()
//("m,mode", "pcd2las : must args --workdir; pcd2las.auto: must args --pcdfile,--lasfile; pcd2las.stationfiles : must args --pcdfile,--lasfile,--jf_station_file, --jd_station_file",
//("h,help", "Print help(VERSION: 1.2)")
// cxxopts::value<std::string>()->default_value("pcd2las.stationfiles"))
(
"h,help"
,
"Print help(VERSION: 1.1)"
)
#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"
" string should be correct"
)
" string should be correct"
)
#endif
#endif
;
;
//options
// .allow_unrecognised_options()
// .add_options()
// ("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"
)
options
.
add_options
(
"options"
)
//("workdir", "自动化的任务根目录", cxxopts::value<std::string>())
(
"f,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"))
(
"jf_station_file"
,
"JF 站心定义文件,必须包含 E0_PROJECT:* N0_PROJECT:* H0_PROJECT:* 三对UTM 站心(偏移)信息"
,
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
>
());
(
"jd_station_file"
,
"JD 站心和校正,必须包含E0_UTM_JD:* N0_UTM_JD:* H0_UTM_JD:* 三对UTM 站心(偏移)信息, 可包含E_OFFSET:* N_OFFSET:* H_OFFSET:* 的校正信息"
,
cxxopts
::
value
<
std
::
string
>
())
(
"fields"
,
"转换到las的pcd的field名字过滤器数组,区分大小写"
,
cxxopts
::
value
<
std
::
vector
<
std
::
string
>
>
()
->
default_value
(
"X,x,Y,y,Z,z,LABEL,Label,label,INTENSITY,Intensity,intensity"
))
//options.add_options("pcd2las")
(
"h,help"
,
"Print help(VERSION: 1.2)"
);
//("pcdfile", "输入pcd文件路径", cxxopts::value<std::string>())
//("o,offsetxyz", "手动指定x,y,z的偏移值", cxxopts::value< std::vector< double> >()->default_value("0.0,0.0,0.0"));
//("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
);
...
@@ -210,9 +175,18 @@ int pcd2las(const cxxopts::ParseResult& argsresult)
...
@@ -210,9 +175,18 @@ int pcd2las(const cxxopts::ParseResult& argsresult)
}
}
jfhd
::
convert
::
Pcd2LasInfo
info
;
jfhd
::
convert
::
Pcd2LasInfo
info
;
if
(
argsresult
.
count
(
"fields"
))
{
const
auto
&
v
=
argsresult
[
"fields"
].
as
<
std
::
vector
<
std
::
string
>>
();
for
(
const
auto
&
i
:
v
)
{
info
.
fieldnames
.
insert
(
i
);
}
}
if
(
argsresult
.
count
(
"offsetxyz"
))
if
(
argsresult
.
count
(
"offsetxyz"
))
{
{
const
auto
values
=
argsresult
[
"offsetxyz"
].
as
<
std
::
vector
<
double
>>
();
const
auto
&
values
=
argsresult
[
"offsetxyz"
].
as
<
std
::
vector
<
double
>>
();
if
(
values
.
size
()
<
3
)
if
(
values
.
size
()
<
3
)
{
{
std
::
cout
<<
"offsetxyz 需要三个偏移值"
<<
std
::
endl
;
std
::
cout
<<
"offsetxyz 需要三个偏移值"
<<
std
::
endl
;
...
@@ -487,7 +461,6 @@ bool ReadJdStationFile(const std::string& filepath, str_dict* jddict)
...
@@ -487,7 +461,6 @@ bool ReadJdStationFile(const std::string& filepath, str_dict* jddict)
return
true
;
return
true
;
}
}
int
pcd2lasByStationFiles
(
const
cxxopts
::
ParseResult
&
argsresult
)
int
pcd2lasByStationFiles
(
const
cxxopts
::
ParseResult
&
argsresult
)
{
{
using
boost
::
filesystem
::
path
;
using
boost
::
filesystem
::
path
;
...
@@ -498,25 +471,14 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
...
@@ -498,25 +471,14 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
constexpr
const
char
*
currentmode
=
"pcd2las.stationfiles"
;
constexpr
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
;
boost
::
system
::
error_code
sys_err_code
;
if
(
argsresult
.
count
(
"jf_station_file"
)
<
1
)
if
(
argsresult
.
count
(
"jf_station_file"
)
<
1
)
{
{
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定觉非站心文件"
<<
std
::
endl
;
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定觉非站心文件"
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
std
::
string
temp
=
argsresult
[
"jf_station_file"
].
as
<
std
::
string
>
();
std
::
string
temp
=
argsresult
[
"jf_station_file"
].
as
<
std
::
string
>
();
// 查找station_jf.txt文件
//path testdir(initial_path());
// path testdir("D:/workspace/JF/repos/cc/fmt_converter/build/src/jfhdconvertor");
//workdir = system_complete(path(workdirpath, portable_name));
//testdir = system_complete(path(temp));
//workdir = system_complete(path(workdirpath));
//workdir = system_complete(path(workdirpath));
path
jf_stationfilepath
(
temp
.
begin
(),
temp
.
end
());
// = initial_path();
path
jf_stationfilepath
(
temp
.
begin
(),
temp
.
end
());
// = initial_path();
...
@@ -525,41 +487,42 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
...
@@ -525,41 +487,42 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
if
(
0
!=
sys_err_code
.
value
()
||
!
exists
(
jf_stationfilepath
)
||
!
is_regular_file
(
jf_stationfilepath
))
if
(
0
!=
sys_err_code
.
value
()
||
!
exists
(
jf_stationfilepath
)
||
!
is_regular_file
(
jf_stationfilepath
))
{
{
std
::
cout
<<
"ERROR:"
<<
currentmode
<<
" 找不到觉非站心文件:"
<<
jf_stationfilepath
.
string
()
<<
" DETAIL:"
<<
sys_err_code
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"ERROR:"
<<
currentmode
<<
" 找不到觉非站心文件:"
<<
jf_stationfilepath
.
string
()
<<
" DETAIL:"
<<
sys_err_code
.
message
()
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
if
(
argsresult
.
count
(
"jd_station_file"
)
<
1
)
if
(
argsresult
.
count
(
"jd_station_file"
)
<
1
)
{
{
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定京东站心文件"
<<
std
::
endl
;
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定京东站心文件"
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
temp
=
argsresult
[
"jd_station_file"
].
as
<
std
::
string
>
();
temp
=
argsresult
[
"jd_station_file"
].
as
<
std
::
string
>
();
auto
jd_stationfilepath
=
system_complete
(
path
(
temp
),
sys_err_code
);
auto
jd_stationfilepath
=
system_complete
(
path
(
temp
),
sys_err_code
);
if
(
0
!=
sys_err_code
.
value
()
||
!
exists
(
jd_stationfilepath
)
||
!
is_regular_file
(
jd_stationfilepath
))
if
(
0
!=
sys_err_code
.
value
()
||
!
exists
(
jd_stationfilepath
)
||
!
is_regular_file
(
jd_stationfilepath
))
{
{
std
::
cout
<<
"ERROR:"
<<
currentmode
<<
" 找不到京东站心文件:"
<<
jf_stationfilepath
.
string
()
<<
" DETAIL:"
<<
sys_err_code
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"ERROR:"
<<
currentmode
<<
" 找不到京东站心文件:"
<<
jf_stationfilepath
.
string
()
<<
" DETAIL:"
<<
sys_err_code
.
message
()
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
temp
=
argsresult
[
"pcdfile"
].
as
<
std
::
string
>
();
temp
=
argsresult
[
"pcdfile"
].
as
<
std
::
string
>
();
if
(
argsresult
.
count
(
"pcdfile"
)
<
1
)
if
(
argsresult
.
count
(
"pcdfile"
)
<
1
)
{
{
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定输入pcd文件"
<<
std
::
endl
;
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定输入pcd文件"
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
//path pcd_filepath(temp);
//path pcd_filepath(temp);
auto
pcd_filepath
=
system_complete
(
path
(
temp
),
sys_err_code
);
auto
pcd_filepath
=
system_complete
(
path
(
temp
),
sys_err_code
);
if
(
0
!=
sys_err_code
.
value
()
||
!
exists
(
pcd_filepath
)
||
!
is_regular_file
(
pcd_filepath
))
if
(
0
!=
sys_err_code
.
value
()
||
!
exists
(
pcd_filepath
)
||
!
is_regular_file
(
pcd_filepath
))
{
{
std
::
cout
<<
"ERROR:"
<<
currentmode
<<
" 指定pcd文件错误:"
<<
jf_stationfilepath
.
string
()
<<
" DETAIL:"
<<
sys_err_code
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"ERROR:"
<<
currentmode
<<
" 指定pcd文件错误:"
<<
jf_stationfilepath
.
string
()
<<
" DETAIL:"
<<
sys_err_code
.
message
()
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
temp
=
argsresult
[
"lasfile"
].
as
<
std
::
string
>
();
temp
=
argsresult
[
"lasfile"
].
as
<
std
::
string
>
();
if
(
argsresult
.
count
(
"lasfile"
)
<
1
)
if
(
argsresult
.
count
(
"lasfile"
)
<
1
)
{
{
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定输入las文件"
<<
std
::
endl
;
std
::
cout
<<
"ERROR: "
<<
currentmode
<<
" 未指定输入las文件"
<<
std
::
endl
;
return
-
1
;
return
EXIT_FAILURE
;
}
}
auto
las_filepath
=
system_complete
(
path
(
temp
),
sys_err_code
);
auto
las_filepath
=
system_complete
(
path
(
temp
),
sys_err_code
);
if
(
!
sys_err_code
&&
exists
(
las_filepath
)
&&
is_regular_file
(
las_filepath
))
if
(
!
sys_err_code
&&
exists
(
las_filepath
)
&&
is_regular_file
(
las_filepath
))
...
@@ -577,19 +540,25 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
...
@@ -577,19 +540,25 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
// 读取taskid_station_jf.txt,taskid_station_jd.txt
// 读取taskid_station_jf.txt,taskid_station_jd.txt
str_dict
jf_station_dict
,
jd_station_dict
;
str_dict
jf_station_dict
,
jd_station_dict
;
if
(
!
ReadJfStationFile
(
jf_stationfilepath
.
string
(),
&
jf_station_dict
))
if
(
!
ReadJfStationFile
(
jf_stationfilepath
.
string
(),
&
jf_station_dict
))
return
-
1
;
return
EXIT_FAILURE
;
if
(
!
ReadJdStationFile
(
jd_stationfilepath
.
string
(),
&
jd_station_dict
))
if
(
!
ReadJdStationFile
(
jd_stationfilepath
.
string
(),
&
jd_station_dict
))
return
-
1
;
return
EXIT_FAILURE
;
jfhd
::
convert
::
Pcd2LasInfo
convert_info
;
jfhd
::
convert
::
Pcd2LasInfo
convert_info
;
if
(
!
CalcConvertInfo
(
jf_station_dict
,
jd_station_dict
,
&
convert_info
))
if
(
!
CalcConvertInfo
(
jf_station_dict
,
jd_station_dict
,
&
convert_info
))
return
-
1
;
return
EXIT_FAILURE
;
std
::
cout
<<
"offsetx = "
<<
convert_info
.
offsetx
<<
std
::
endl
;
std
::
cout
<<
"offsetx = "
<<
convert_info
.
offsetx
<<
std
::
endl
;
std
::
cout
<<
"offsety = "
<<
convert_info
.
offsety
<<
std
::
endl
;
std
::
cout
<<
"offsety = "
<<
convert_info
.
offsety
<<
std
::
endl
;
std
::
cout
<<
"offsetz = "
<<
convert_info
.
offsetz
<<
std
::
endl
;
std
::
cout
<<
"offsetz = "
<<
convert_info
.
offsetz
<<
std
::
endl
;
const
auto
&
v
=
argsresult
[
"fields"
].
as
<
std
::
vector
<
std
::
string
>
>
();
for
(
const
auto
&
i
:
v
)
{
convert_info
.
fieldnames
.
insert
(
i
);
}
std
::
string
errormsg
;
std
::
string
errormsg
;
if
(
!
jfhd
::
convert
::
Convertor
::
Pcd2Las
(
pcd_filepath
.
string
(),
las_filepath
.
string
(),
convert_info
,
&
errormsg
))
if
(
!
jfhd
::
convert
::
Convertor
::
Pcd2Las
(
pcd_filepath
.
string
(),
las_filepath
.
string
(),
convert_info
,
&
errormsg
))
{
{
...
@@ -604,541 +573,6 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
...
@@ -604,541 +573,6 @@ int pcd2lasByStationFiles(const cxxopts::ParseResult& argsresult)
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
}
}
return
0
;
return
EXIT_SUCCESS
;
}
}
//#include <corecrt_io.h>
//#include <pcl/io/pcd_io.h>
//#include <pcl/point_types.h>
//#include <pcl/PCLPointCloud2.h>
//
////typedef struct PointXYZIT {
//// PCL_ADD_POINT4D
////
//// float label;
//// float intensity;
//// EIGEN_MAKE_ALIGNED_OPERATOR_NEW // make sure our new allocators are aligned
////} EIGEN_ALIGN16 PPoint;
//
//
////typedef struct PointXYZIT {
//// PCL_ADD_POINT4D
////
//// float label;
//// float intensity;
//// EIGEN_MAKE_ALIGNED_OPERATOR_NEW // make sure our new allocators are aligned
////} EIGEN_ALIGN16 PPoint;
////
////POINT_CLOUD_REGISTER_POINT_STRUCT(
//// PointXYZIT, (float, x, x) (float, y, y)(float, z, z)(float, intensity, intensity)(float, label, label))
//
//
// //pdal::Dimension::Type GetLasDimDataType(const pcl::PCLPointField& field);
//#include <unordered_map>
//
//
//void TestPcd2Las()
//{
// std::string pcdfilepath{ "E:/data/jd/task1-2/1106/JF_PCD/12_ground_utm_add.pcd" };
//
// Eigen::Vector4f origin;
// Eigen::Quaternionf orientation;
// pcl::PCLPointCloud2 pcloud;
// pcl::io::loadPCDFile(pcdfilepath, pcloud, origin, orientation);
//
// //pcl::PointCloud<PointXYZIT>::Ptr cloud(new pcl::PointCloud<PointXYZIT>);
// //pcl::io::loadPCDFile(pcdfilepath, *cloud);
//
// // pcd field 变换到 las的dim
// std::unordered_map<std::string, pdal::Dimension::Id> dict_pclfieldname_lasid;
// pdal::PointTable table;
// auto layerout = table.layout();
// for (auto field : pcloud.fields)
// {
// if (0 == field.name.compare("_"))
// continue;
//
// auto dimdatatype = GetLasDimDataType(field);
// if (pdal::Dimension::Type::None == dimdatatype)
// {
// // TODO::
// continue;
// }
//
// pdal::Dimension::Id dim = pdal::Dimension::id(field.name);
// if (pdal::Dimension::Id::Unknown != dim)
// {
// layerout->registerDim(dim);
// }
// else
// {
// dim = layerout->assignDim(field.name, dimdatatype);
// }
//
// dict_pclfieldname_lasid.emplace(std::make_pair(field.name, dim));
// }
//
// pdal::PointViewPtr view(new pdal::PointView(table));
// std::uint64_t width = pcloud.width;
// std::uint64_t height = pcloud.height;
// std::uint64_t point_count = width * height;
// std::uint64_t point_step = pcloud.point_step;
//
// std::uint64_t ipoint = 0;
//
// for (std::uint64_t row = 0; row < height; ++row)
// {
// const std::uint8_t* row_data = &pcloud.data[row * pcloud.row_step];
// for (std::uint32_t col = 0; col < pcloud.width; ++col)
// {
// std::cout << ipoint << ":";
// const std::uint8_t* msg_data = row_data + col * point_step;
//
// for (const auto& item : pcloud.fields)
// {
// if (dict_pclfieldname_lasid.end() == dict_pclfieldname_lasid.find(item.name))
// continue;
//
// //constexpr pcl::PCLPointField::PointFieldTypes field_type = (pcl::PCLPointField::PointFieldTypes)item.datatype;
//
// switch (item.datatype) {
// case pcl::PCLPointField::INT8: {
// pcl::traits::asType<pcl::PCLPointField::INT8>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::INT8>::type));
// //GetValueFunctor<pcl::PCLPointField::INT8> funcotr;
// //funcotr(msg_data, item);
// }break;
// case pcl::PCLPointField::UINT8:
// {
// pcl::traits::asType<pcl::PCLPointField::UINT8>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::UINT8>::type));
// }break;
// case pcl::PCLPointField::INT16:
// {
// pcl::traits::asType<pcl::PCLPointField::INT16>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::INT16>::type));
// }break;
// case pcl::PCLPointField::UINT16:
// {
// pcl::traits::asType<pcl::PCLPointField::UINT16>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::UINT16>::type));
// }break;
// case pcl::PCLPointField::INT32:
// {
// pcl::traits::asType<pcl::PCLPointField::INT32>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::INT32>::type));
// }break;
// case pcl::PCLPointField::UINT32:
// {
// pcl::traits::asType<pcl::PCLPointField::UINT32>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::UINT32>::type));
// auto it = dict_pclfieldname_lasid.find(item.name);
// if (it != dict_pclfieldname_lasid.end())
// {
// view->setField(it->second, ipoint, val);
// }
// }break;
// case pcl::PCLPointField::FLOAT32:
// {
// pcl::traits::asType<pcl::PCLPointField::FLOAT32>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::FLOAT32>::type));
//
// auto it = dict_pclfieldname_lasid.find(item.name);
// if (it != dict_pclfieldname_lasid.end())
// {
// view->setField(it->second, ipoint, (double)val);
// }
// // TODO: 判断x,y,z 进行加减
// }break;
// case pcl::PCLPointField::FLOAT64:
// {
// pcl::traits::asType<pcl::PCLPointField::FLOAT64>::type val;
// memcpy(&val, msg_data + item.offset, sizeof(pcl::traits::asType<pcl::PCLPointField::FLOAT64>::type));
//
// auto it = dict_pclfieldname_lasid.find(item.name);
// if (it != dict_pclfieldname_lasid.end())
// {
// view->setField(it->second, ipoint, val);
// }
// }break;
// default:
// break;
// }
// }
// ++ipoint;
//
// std::cout << std::endl;
// }
// }
//
// std::string lasfilepath{ "E:/data/jd/task1-2/1106/JF_PCD/12_ground_utm_add_myself.las" };
// pdal::Options las_options;
// las_options.add("filename", lasfilepath);
// las_options.add("extra_dims", "all");
// las_options.add("scale_x", 1.0e-5);
// las_options.add("scale_y", 1.0e-5);
// las_options.add("scale_z", 1.0e-5);
// pdal::Uuid uuid;
// uuid.parse("C8DED732-F71F-44D7-A62E-24F7F8A43E69");
// las_options.add("project_id", uuid);
//
// pdal::BufferReader bufferreader;
// bufferreader.addView(view);
//
// pdal::StageFactory factory;
// pdal::Stage* writer = factory.createStage("writers.las");
// writer->setOptions(las_options);
// writer->setInput(bufferreader);
// writer->prepare(table);
// writer->execute(table);
//
// //las_options.add()
//
// //pdal::PointTable table;
// //auto layerout = table.layout();
// //pdal::PointLayout layerout;
// //layerout->registerDim(pdal::Dimension::Id::X);
// //layerout->registerDim(pdal::Dimension::Id::Y);
// //layerout->registerDim(pdal::Dimension::Id::Z);
//
// // ȱ�ٱ��� dim field ��Ӧ��ϵ
// //for (auto field : pcloud.fields)
// //{
// // if (0 == field.name.compare("_"))
// // continue;
//
// // auto dim = pdal::Dimension::id(field.name);
// // if (pdal::Dimension::Id::Unknown != dim)
// // {
// // layerout->registerDim(dim);
// // continue;
// // }
//
// // auto dimdatatype = GetLasDimDataType(field);
// // if (pdal::Dimension::Type::None == dimdatatype)
// // {
// // // TODO::
// // continue;
// // }
//
// // auto customdim = layerout->assignDim(field.name, dimdatatype);
// //}
//
//
//}
//
//pdal::Dimension::Type GetLasDimDataType(const pcl::PCLPointField& field)
//{
// switch (field.datatype)
// {
// case pcl::PCLPointField::INT8:
// {
// return pdal::Dimension::Type::Signed8;
// }break;
// case pcl::PCLPointField::UINT8:
// {
// return pdal::Dimension::Type::Unsigned8;
// }break;
// case pcl::PCLPointField::INT16:
// {
// return pdal::Dimension::Type::Signed16;
//
// }break;
// case pcl::PCLPointField::UINT16:
// {
// return pdal::Dimension::Type::Unsigned16;
// }break;
// case pcl::PCLPointField::INT32:
// {
// return pdal::Dimension::Type::Signed32;
// }break;
// case pcl::PCLPointField::UINT32:
// {
// return pdal::Dimension::Type::Unsigned32;
// }break;
// case pcl::PCLPointField::FLOAT32:
// {
// return pdal::Dimension::Type::Float;
// }break;
// case pcl::PCLPointField::FLOAT64:
// {
// return pdal::Dimension::Type::Double;
// }break;
// default:
// return pdal::Dimension::Type::None;
// }
//}
//
//void TestPcdreader()
//{
// std::string pcdfilepath{ "E:/data/jd/task1-2/1106/JF_PCD/12_ground_utm_add.pcd" };
//
// pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGBA>);
// //pcl::PointCloud<PPoint>::Ptr cloud(new pcl::PointCloud<PPoint>);
//// pcl::io::loadPCDFile(pcdfilepath, *cloud);
//
//
//
//
// //pcl::PCDReader p;
//
//
// pcl::PCLPointCloud2 pcd2;
// Eigen::Vector4f origin;
// Eigen::Quaternionf orientation;
// int res = pcl::io::loadPCDFile(pcdfilepath, pcd2, origin, orientation);
//
// //for (auto i : pcd2->points)
// //{
// // std::cout << "x=" << i.x;
// // std::cout << " y=" << i.y;
// // std::cout << " z=" << i.z << std::endl;
// // break;
// //}
//
// std::cout << "end" << std::endl;
//}
//
//#include <pdal/io/LasReader.hpp>
//#include <pdal/io/LasHeader.hpp>
//#include <pdal/io/LasVLR.hpp>
//#include <pdal/io/LasUtils.hpp>
//#include <pdal/Dimension.hpp>
//#include <vector>
//
//using DT = pdal::Dimension::Type;
//const pdal::Dimension::Type lastypes[] = {
// DT::None, DT::Unsigned8, DT::Signed8, DT::Unsigned16, DT::Signed16,
// DT::Unsigned32, DT::Signed32, DT::Unsigned64, DT::Signed64,
// DT::Float, DT::Double
//};
//
//void pdal::ExtraBytesIf::setType(uint8_t lastype)
//{
// m_fieldCnt = 1;
// while (lastype > 10)
// {
// m_fieldCnt++;
// lastype -= 10;
// }
//
// m_type = lastypes[lastype];
// if (m_type == Dimension::Type::None)
// m_fieldCnt = 0;
//}
//
//
//void pdal::ExtraBytesIf::readFrom(const char *buf)
//{
// LeExtractor extractor(buf, sizeof(ExtraBytesSpec));
// uint16_t dummy16;
// uint32_t dummy32;
// uint64_t dummy64;
// double dummyd;
// uint8_t options;
// uint8_t type;
//
// uint8_t SCALE_MASK = 1 << 3;
// uint8_t OFFSET_MASK = 1 << 4;
//
// extractor >> dummy16 >> type >> options;
// extractor.get(m_name, 32);
// extractor >> dummy32;
// for (size_t i = 0; i < 3; ++i)
// extractor >> dummy64; // No data field.
// for (size_t i = 0; i < 3; ++i)
// extractor >> dummyd; // Min.
// for (size_t i = 0; i < 3; ++i)
// extractor >> dummyd; // Max.
// for (size_t i = 0; i < 3; ++i)
// extractor >> m_scale[i];
// for (size_t i = 0; i < 3; ++i)
// extractor >> m_offset[i];
// extractor.get(m_description, 32);
//
// setType(type);
// if (m_type == Dimension::Type::None)
// m_size = options;
// if (!(options & SCALE_MASK))
// for (size_t i = 0; i < 3; ++i)
// m_scale[i] = 1.0;
// if (!(options & OFFSET_MASK))
// for (size_t i = 0; i < 3; ++i)
// m_offset[i] = 0.0;
//}
//
//std::vector<pdal::ExtraDim> pdal::ExtraBytesIf::toExtraDims()
//{
// std::vector<ExtraDim> eds;
//
// if (m_type == Dimension::Type::None)
// {
// ExtraDim ed(m_name, Dimension::Type::None);
// ed.m_size = m_size;
// eds.push_back(ed);
// }
// else if (m_fieldCnt == 1)
// {
// ExtraDim ed(m_name, m_type, m_scale[0], m_offset[0]);
// eds.push_back(ed);
// }
// else
// {
// for (size_t i = 0; i < m_fieldCnt; ++i)
// {
// ExtraDim ed(m_name + std::to_string(i), m_type,
// m_scale[i], m_offset[i]);
// eds.push_back(ed);
// }
// }
// return eds;
//}
//
//static bool ReadExtraBytesVlr(pdal::LasHeader& header, std::vector<pdal::ExtraDim>& extraDims)
//{
// using namespace pdal;
//
// const LasVLR *vlr = header.findVlr(SPEC_USER_ID, EXTRA_BYTES_RECORD_ID);
// if (!vlr)
// {
// return false;
// }
//
// size_t size = vlr->dataLen();
// if (size % sizeof(ExtraBytesSpec) != 0)
// {
// //ccLog::Warning("[LAS] Bad size for extra bytes VLR. Ignoring.");
// return false;
// }
// size_t count = size / sizeof(ExtraBytesSpec);
// //ccLog::PrintDebug("[LAS] VLR count: " + QString::number(count));
//
// try
// {
// const char* pos = vlr->data();
// for (size_t i = 0; i < count; ++i)
// {
// ExtraBytesIf eb;
// eb.readFrom(pos);
// pos += sizeof(ExtraBytesSpec);
//
// std::vector<ExtraDim> eds = eb.toExtraDims();
// for (const ExtraDim& ed : eds)
// {
// // ccLog::PrintDebug(QString("[LAS] VLR #%1: %2").arg(i + 1).arg(QString::fromStdString(ed.m_name)));
// extraDims.push_back(ed);
// }
// }
// }
// catch (const std::bad_alloc&)
// {
// //ccLog::Warning("[LAS] Not enough memory to retrieve the extra bytes fields.");
// return false;
// }
//
// return true;
//}
//
//void TestPdalReadLas()
//{
// using namespace pdal;
//
// std::string lasfilepath{ "E:/data/jd/task1-2/1106/JF_PCD/12_ground_utm_add_cc.las" };
// pdal::PointTable table;
// pdal::LasReader las_reader;
//
// pdal::Options las_opts;
// las_opts.add(pdal::Option("filename", lasfilepath));
// las_reader.setOptions(las_opts);
// las_reader.prepare(table);
// auto las_header = las_reader.header();
//
// std::vector<pdal::ExtraDim> extradims;
// ReadExtraBytesVlr(las_header, extradims);
//
// //las_opts.add(pdal::Option("extra_dims", "label=float"));
//
// StringList extraNamesToLoad;
// std::string extraDimsArg;
// for (unsigned i = 0; i < extradims.size(); ++i)
// {
// //if (s_lasOpenDlg->doLoadEVLR(i))
// //{
// extraDimsArg += extradims[i].m_name + "=" + pdal::Dimension::interpretationName(extradims[i].m_dimType.m_type) + ",";
// extraNamesToLoad.push_back(extradims[i].m_name);
// //}
// }
// pdal::Options las_opts2;
// las_opts2.add(pdal::Option("extra_dims", extraDimsArg));
// las_reader.addOptions(las_opts2);
// las_reader.prepare(table);
//
// pdal::PointViewSet point_view_set = las_reader.execute(table);
//
// pdal::PointViewPtr point_view = *point_view_set.begin();
// pdal::Dimension::IdList dims = point_view->dims();
// auto layout = point_view->layout();
//
// //ͷ�ļ���Ϣ
// unsigned int PointCount = las_header.pointCount();
// //char* projstr = table.spatialRef().getWKT(pdal::SpatialReference::e
//}
//
//void TestPdalWriteLas()
//{
// std::string lasfilepath{ "E:/data/jd/task1-2/1106/JF_PCD/12_ground_utm_add1.las" };
//
// pdal::Options las_options;
// las_options.add("filename", lasfilepath);
// las_options.add("extra_dims", "all");
// las_options.add("scale_x", 0.01);
// las_options.add("scale_y", 0.01);
// las_options.add("scale_z", 0.01);
// las_options.add("offset_x", 0.0);
// las_options.add("offset_y", 0.0);
// las_options.add("offset_z", 0.0);
// pdal::Uuid uuid;
// uuid.parse("C8DED732-F71F-44D7-A62E-24F7F8A43E69");
// las_options.add("project_id", uuid);
//
// //las_options.add()
//
// pdal::PointTable table;
// auto layerout = table.layout();
// //pdal::PointLayout layerout;
// layerout->registerDim(pdal::Dimension::Id::X);
// layerout->registerDim(pdal::Dimension::Id::Y);
// layerout->registerDim(pdal::Dimension::Id::Z);
// //layerout.registerDim(pdal::Dimension::Id::lay)
// auto labelid = layerout->assignDim("label", pdal::Dimension::Type::Double);
//
// pdal::PointViewPtr view(new pdal::PointView(table));
// for (int i = 0; i < 100; ++i)
// {
// view->setField(pdal::Dimension::Id::X, i, i * 10.0);
// view->setField(pdal::Dimension::Id::Y, i, i * 10.0);
// view->setField(pdal::Dimension::Id::Z, i, i * 10.0);
// view->setField(labelid, i, i);
// }
//
// pdal::BufferReader bufferreader;
// bufferreader.addView(view);
//
// pdal::StageFactory factory;
// pdal::Stage* writer = factory.createStage("writers.las");
// writer->setOptions(las_options);
// writer->setInput(bufferreader);
// writer->prepare(table);
// writer->execute(table);
//}
//
//#include <pcl/io/pcd_io.h>
//
////POINT_CLOUD_REGISTER_POINT_STRUCT(
//// PointXYZIT, (float, x, x)(float, y, y)(float, z, z)(float, intensity, intensity))
// typedef pcl::PointCloud<PPoint> PPointCloud;
//void TestPCLRead()
//{
// PPointCloud* pcld = new PPointCloud();
// std::string filepath = "E:/gdata/gjd/task1-2/1106/JF_PCD/12_ground_utm_add.pcd";
// pcl::io::loadPCDFile(filepath, *pcld);
//}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment