File tree Expand file tree Collapse file tree 3 files changed +47
-1
lines changed
Expand file tree Collapse file tree 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,38 @@ namespace pdal
1212{
1313 namespace capi
1414 {
15+ size_t PDALGetDimTypeListSize (PDALDimTypeListPtr types)
16+ {
17+ pdal::capi::DimTypeList *wrapper = reinterpret_cast <pdal::capi::DimTypeList *>(types);
18+
19+ size_t size = 0 ;
20+
21+ if (wrapper && wrapper->get ())
22+ {
23+ try
24+ {
25+ pdal::DimTypeList *list = wrapper->get ();
26+ size = list->size ();
27+ }
28+ catch (const std::exception &e)
29+ {
30+ printf (" %s\n " , e.what ());
31+ }
32+ }
33+
34+ return size;
35+ }
36+
1537 PDALDimTypeListPtr PDALGetPointLayoutDimTypes (PDALPointLayoutPtr layout)
1638 {
1739 PDALDimTypeListPtr types = NULL ;
1840 pdal::PointLayoutPtr nativeLayout = reinterpret_cast <pdal::PointLayoutPtr>(layout);
1941
2042 if (nativeLayout)
2143 {
22- types = new pdal::capi::DimTypeList (new pdal::DimTypeList (nativeLayout->dimTypes ()));
44+ pdal::DimTypeList *list = new pdal::DimTypeList (nativeLayout->dimTypes ());
45+
46+ types = new pdal::capi::DimTypeList (list);
2347 }
2448
2549 return types;
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ namespace pdal
1616 extern " C"
1717 {
1818#endif
19+ PDAL_C_API size_t PDALGetDimTypeListSize (PDALDimTypeListPtr types);
20+
1921 PDAL_C_API PDALDimTypeListPtr PDALGetPointLayoutDimTypes (PDALPointLayoutPtr layout);
2022
2123 PDAL_C_API void PDALDisposeDimTypeList (PDALDimTypeListPtr types);
Original file line number Diff line number Diff line change @@ -65,6 +65,25 @@ static void teardownPointLayoutTest(void *arg)
6565 PDALDisposePipeline(gPipeline);
6666}
6767
68+ TEST testPDALGetPointLayoutDimTypes(void)
69+ {
70+ ASSERT(gLayout);
71+ PDALDimTypeListPtr types = PDALGetPointLayoutDimTypes(NULL);
72+ ASSERT_EQ(NULL, types);
73+
74+ types = PDALGetPointLayoutDimTypes(gLayout);
75+ ASSERT(types);
76+
77+ size_t size = PDALGetDimTypeListSize(types);
78+ ASSERT(size > 0);
79+
80+ PDALDisposeDimTypeList(types);
81+ size = PDALGetDimTypeListSize(types);
82+ ASSERT_EQ(0, size);
83+
84+ PASS();
85+ }
86+
6887TEST testPDALGetDimSize(void)
6988{
7089 ASSERT(gLayout);
@@ -131,6 +150,7 @@ GREATEST_SUITE(PointLayoutTest)
131150 SET_SETUP(setupPointLayoutTest, NULL);
132151 SET_TEARDOWN(teardownPointLayoutTest, NULL);
133152
153+ RUN_TEST(testPDALGetPointLayoutDimTypes);
134154 RUN_TEST(testPDALGetDimSize);
135155 RUN_TEST(testPDALGetDimPackedOffset);
136156 RUN_TEST(testPDALGetPointSize);
You can’t perform that action at this time.
0 commit comments