Skip to content

Commit 15eb083

Browse files
committed
Add function to retrieve layout from PDALPointView.
1 parent 87d4b1f commit 15eb083

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

source/pdal/capi/Forward.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ namespace pdal
3636

3737
#endif /* __cplusplus */
3838

39+
3940
/// A pointer to a C++ pdal::capi::Pipeline object
4041
typedef void* PDALPipelinePtr;
4142

43+
/// A pointer to a C++ pdal::PointLayout
44+
typedef void* PDALPointLayoutPtr;
45+
4246
/// A pointer to a C++ pdal::capi::PointView object
4347
typedef void* PDALPointViewPtr;
4448

source/pdal/capi/PointView.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ namespace pdal
102102

103103
return result;
104104
}
105+
106+
PDALPointLayoutPtr PDALGetPointViewLayout(PDALPointViewPtr view)
107+
{
108+
pdal::capi::PointView *wrapper = reinterpret_cast<pdal::capi::PointView *>(view);
109+
110+
PDALPointLayoutPtr layout = nullptr;
111+
112+
if (wrapper && *wrapper)
113+
{
114+
layout = (*wrapper)->layout();
115+
}
116+
117+
return layout;
118+
}
105119
}
106120
}
107121
}

source/pdal/capi/PointView.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ namespace pdal
8989
*/
9090
PDAL_C_API size_t PDALGetPointViewWkt(PDALPointViewPtr view, char *wkt, size_t size, bool pretty);
9191

92-
//! PDAL_C_API PDALPointLayoutPtr PDALGetPointViewLayout(PDALPointViewPtr view);
92+
/**
93+
* Returns the point layout for the provided point `view`.
94+
*
95+
* @param view The point view
96+
* @return The point layout
97+
*/
98+
PDAL_C_API PDALPointLayoutPtr PDALGetPointViewLayout(PDALPointViewPtr view);
9399

94100
/**
95101
* Fill a buffer with point data specified by the dimension list.

tests/pdal/capi/PointViewTest.c.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,25 @@ TEST testPDALGetPointViewWkt(void)
216216
PASS();
217217
}
218218

219+
220+
TEST testPDALGetPointViewLayout(void)
221+
{
222+
PDALPointLayoutPtr layout = PDALGetPointViewLayout(NULL);
223+
ASSERT_FALSE(layout != NULL);
224+
225+
PDALResetPointViewCollection(gPointViewCollection);
226+
bool hasNext = PDALHasNextPointView(gPointViewCollection);
227+
ASSERT_FALSE(!hasNext);
228+
229+
PDALPointViewPtr view = PDALGetNextPointView(gPointViewCollection);
230+
ASSERT_FALSE(view == NULL);
231+
232+
layout = PDALGetPointViewLayout(view);
233+
ASSERT_FALSE(layout == NULL);
234+
235+
PASS();
236+
}
237+
219238
GREATEST_SUITE(PointViewTest)
220239
{
221240
SET_SETUP(setupPointViewTest, NULL);
@@ -227,6 +246,7 @@ GREATEST_SUITE(PointViewTest)
227246
RUN_TEST(testPDALClonePointView);
228247
RUN_TEST(testPDALGetPointViewProj4);
229248
RUN_TEST(testPDALGetPointViewWkt);
249+
RUN_TEST(testPDALGetPointViewLayout);
230250

231251
SET_SETUP(NULL, NULL);
232252
SET_TEARDOWN(NULL, NULL);

0 commit comments

Comments
 (0)