Skip to content

Commit ddf2654

Browse files
committed
Merge branch 'PointView' into 'master'
Add functions for PointView, PointLayout, and DimType See merge request nublar/pdal-c!2
2 parents 1557385 + 51f4410 commit ddf2654

28 files changed

+1508
-445
lines changed

.gitlab-ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ test-x64-windows-release:
7373
before_script:
7474
- cd %VCPKG_ROOT%/installed/x64-windows/bin
7575
script:
76+
- set GDAL_DATA=%VCPKG_ROOT%\installed\x64-windows\share\gdal
77+
- set PROJ_LIB=%VCPKG_ROOT%\installed\x64-windows\share\proj4
78+
- copy proj_4_9.dll proj.dll
7679
- "%CI_PROJECT_DIR%/build/build-x64-windows-release/bin/test_pdal_c"
7780
cache:
7881
key: build-x64-windows-release
@@ -86,7 +89,10 @@ test-x64-windows-debug:
8689
before_script:
8790
- cd %VCPKG_ROOT%/installed/x64-windows/debug/bin
8891
script:
89-
- "%CI_PROJECT_DIR%/build/build-x64-windows-debug/bin/test_pdal_cd"
92+
- set GDAL_DATA=%VCPKG_ROOT%\installed\x64-windows\share\gdal
93+
- set PROJ_LIB=%VCPKG_ROOT%\installed\x64-windows\share\proj4
94+
- copy proj_4_9_d.dll proj.dll
95+
- "%CI_PROJECT_DIR%/build/build-x64-windows-debug/bin/test_pdal_cd"
9096
cache:
9197
key: build-x64-windows-debug
9298
paths:
@@ -174,8 +180,8 @@ build-x64-linux-debug-alpine:
174180
.job_template: &test-linux
175181
stage: test
176182
script:
183+
- rm -rf coverage_pdal_c
177184
- make coverage_pdal_c
178-
- ls -l
179185
cache:
180186
key: "$CI_JOB_NAME"
181187
policy: pull

.vscode/launch.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,16 @@
1212
"args": [],
1313
"stopAtEntry": false,
1414
"cwd": "${env:VCPKG_ROOT}\\installed\\x64-windows\\debug\\bin",
15-
"environment": [],
15+
"environment": [
16+
{
17+
"name": "GDAL_DATA",
18+
"value": "${env:VCPKG_ROOT}\\installed\\x64-windows\\share\\gdal"
19+
},
20+
{
21+
"name": "PROJ_LIB",
22+
"value": "${env:VCPKG_ROOT}\\installed\\x64-windows\\share\\proj4"
23+
}
24+
],
1625
"externalConsole": true,
1726
"internalConsoleOptions": "openOnSessionStart"
1827
}

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
3737
'build/*'
3838
'cmake/*'
3939
'tests/*'
40+
'tests/pdal/capi/*'
4041
'/usr/include/*'
4142
)
4243
endif()

make.bat

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
:: TODO Auto-detect latest platform
55
set SCRIPT_DIR=%~dp0
66

7-
::cmake .. "-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake" -G "Sublime Text 2 - Ninja" -DVCPKG_TARGET_TRIPLET=x86-windows-static -DCMAKE_BUILD_TYPE=Debug
8-
97
if not defined TOOLCHAIN set TOOLCHAIN=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake
108
if not defined BUILD_TYPE set BUILD_TYPE=Release
119
if not defined ARCH set ARCH=x64

source/pdal/capi/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ find_package(PDAL REQUIRED CONFIG)
44
message(STATUS "Found PDAL ${PDAL_VERSION}")
55

66
set(SOURCES
7+
DimType.cpp
78
Pipeline.cpp
9+
PointLayout.cpp
810
PointView.cpp
9-
PointViewCollection.cpp
11+
PointViewIterator.cpp
1012
)
1113

1214
set(HEADERS
1315
Defines.h
16+
DimType.h
1417
Forward.h
1518
Pipeline.h
19+
PointLayout.h
1620
PointView.h
17-
PointViewCollection.h
21+
PointViewIterator.h
1822
)
1923

2024
set(DEPENDENCIES

source/pdal/capi/DimType.cpp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (c) Simverge Software LLC - All Rights Reserved
3+
*/
4+
5+
#include "DimType.h"
6+
#include <pdal/DimType.hpp>
7+
8+
namespace pdal
9+
{
10+
namespace capi
11+
{
12+
size_t PDALGetDimTypeListSize(PDALDimTypeListPtr types)
13+
{
14+
pdal::capi::DimTypeList *wrapper = reinterpret_cast<pdal::capi::DimTypeList *>(types);
15+
16+
size_t size = 0;
17+
18+
if (wrapper && wrapper->get())
19+
{
20+
try
21+
{
22+
pdal::DimTypeList *list = wrapper->get();
23+
size = list->size();
24+
}
25+
catch (const std::exception &e)
26+
{
27+
printf("%s\n", e.what());
28+
}
29+
}
30+
31+
return size;
32+
}
33+
34+
PDALDimType PDALGetInvalidDimType()
35+
{
36+
PDALDimType dim ={
37+
static_cast<uint32_t>(pdal::Dimension::id("")), static_cast<uint32_t>(pdal::Dimension::type("")),
38+
1.0, 0.0
39+
};
40+
41+
return dim;
42+
}
43+
44+
size_t PDALGetDimTypeIdName(PDALDimType dim, char *name, size_t size)
45+
{
46+
size_t result = 0;
47+
48+
if (name && size > 0)
49+
{
50+
std::string s = pdal::Dimension::name(
51+
static_cast<pdal::Dimension::Id>(dim.id));
52+
std::strncpy(name, s.c_str(), size);
53+
result = std::min(std::strlen(name), size);
54+
}
55+
56+
return result;
57+
}
58+
59+
size_t PDALGetDimTypeInterpretationName(PDALDimType dim, char *name, size_t size)
60+
{
61+
size_t result = 0;
62+
63+
if (name && size > 0)
64+
{
65+
std::string s = pdal::Dimension::interpretationName(
66+
static_cast<pdal::Dimension::Type>(dim.type));
67+
std::strncpy(name, s.c_str(), size);
68+
result = std::min(std::strlen(name), size);
69+
}
70+
71+
return result;
72+
}
73+
74+
PDALDimType PDALGetDimType(PDALDimTypeListPtr types, size_t index)
75+
{
76+
pdal::capi::DimTypeList *wrapper = reinterpret_cast<pdal::capi::DimTypeList *>(types);
77+
78+
PDALDimType dim = PDALGetInvalidDimType();
79+
// PDALDimType dim = {
80+
// static_cast<uint32_t>(pdal::Dimension::id("")), static_cast<uint32_t>(pdal::Dimension::type("")),
81+
// 1.0, 0.0
82+
// };
83+
84+
if (wrapper && wrapper->get())
85+
{
86+
try
87+
{
88+
pdal::DimTypeList *list = wrapper->get();
89+
90+
if (index < list->size())
91+
{
92+
pdal::DimType nativeDim = list->at(index);
93+
dim.id = static_cast<uint32_t>(nativeDim.m_id);
94+
dim.type = static_cast<uint32_t>(nativeDim.m_type);
95+
dim.scale = nativeDim.m_xform.m_scale.m_val;
96+
dim.offset = nativeDim.m_xform.m_offset.m_val;
97+
}
98+
}
99+
catch (const std::exception &e)
100+
{
101+
printf("%s\n", e.what());
102+
}
103+
}
104+
105+
return dim;
106+
}
107+
108+
void PDALDisposeDimTypeList(PDALDimTypeListPtr types)
109+
{
110+
if (types)
111+
{
112+
pdal::capi::DimTypeList *ptr = reinterpret_cast<pdal::capi::DimTypeList *>(types);
113+
delete ptr;
114+
}
115+
}
116+
}
117+
}

source/pdal/capi/DimType.h

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright (c) Simverge Software LLC - All Rights Reserved
3+
*/
4+
5+
#ifndef PDAL_CAPI_DIMTYPE_H
6+
#define PDAL_CAPI_DIMTYPE_H
7+
8+
#include "Forward.h"
9+
10+
#ifdef __cplusplus
11+
12+
namespace pdal
13+
{
14+
namespace capi
15+
{
16+
extern "C"
17+
{
18+
#endif
19+
/**
20+
* Returns the number of elements in a dimension type list.
21+
*
22+
* @param types A pointer to the dimension type list
23+
* @return The number of dimension type elements in the list
24+
*/
25+
PDAL_C_API size_t PDALGetDimTypeListSize(PDALDimTypeListPtr types);
26+
27+
/**
28+
* Returns the invalid dimension type. This dimension type has:
29+
* - An ID value of 0 that corresponds to pdal::Dimension::Id::Unknown
30+
* - An interpretation (data type) value of 0 that corresponds to pdal::Dimension::Type::None
31+
* - A scale value of 1.0
32+
* - An offset value of 0.0
33+
*
34+
* @return The invalid dimension type
35+
*/
36+
PDAL_C_API PDALDimType PDALGetInvalidDimType();
37+
38+
/**
39+
* Returns the dimension type at the provided `index` from a dimension type list.
40+
*
41+
* @param types A pointer to the dimension type list
42+
* @param index The index of the dimension type element
43+
* @return The element the `index`
44+
* or the value returned by PDALGetInvalidDimType if the index is out of the list's bounds
45+
*/
46+
PDAL_C_API PDALDimType PDALGetDimType(PDALDimTypeListPtr types, size_t index);
47+
48+
/**
49+
* Retrieves the name of a dimension type's ID.
50+
*
51+
* @param dim The dimension type
52+
* @param[out] name The buffer used to store the retrieved name
53+
* @param size The size of the `name` buffer which will also be the maximum size of the retrieved name
54+
* @return The size of the retrieved ID name
55+
* or zero if the `name` buffer is NULL or buffer `size` is zero
56+
*/
57+
PDAL_C_API size_t PDALGetDimTypeIdName(PDALDimType dim, char *name, size_t size);
58+
59+
/**
60+
* Retrieves the name of a dimension type's interpretation, i.e., its data type.
61+
*
62+
* @param dim The dimension type
63+
* @param[out] name The buffer used to store the retrieved name
64+
* @param size The size of the `name` buffer which will also be the maximum size of the retrieved name
65+
* @return The size of the retrieved interpretation name
66+
* or zero if the `name` buffer is NULL or buffer`size` is zero
67+
*/
68+
PDAL_C_API size_t PDALGetDimTypeInterpretationName(PDALDimType dim, char *name, size_t size);
69+
70+
/**
71+
* Disposes the provided dimension type list.
72+
*
73+
* @param types A pointer to the dimension type list
74+
*/
75+
PDAL_C_API void PDALDisposeDimTypeList(PDALDimTypeListPtr types);
76+
77+
#ifdef __cplusplus
78+
}
79+
}
80+
81+
}
82+
#endif
83+
#endif

source/pdal/capi/Forward.h

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,56 @@
1818
#ifdef __cplusplus
1919
#include <memory>
2020
#include <set>
21+
#include <vector>
2122

2223
namespace pdal
2324
{
25+
struct DimType;
2426
class PipelineExecutor;
2527
class PointView;
2628

2729
using PointViewPtr = std::shared_ptr<PointView>;
30+
using DimTypeList = std::vector<DimType>;
2831

2932
namespace capi
3033
{
31-
class PointViewCollection;
34+
class PointViewIterator;
3235
using Pipeline = std::unique_ptr<pdal::PipelineExecutor>;
3336
using PointView = pdal::PointViewPtr;
37+
using DimTypeList = std::unique_ptr<pdal::DimTypeList>;
3438
}
3539
}
3640

41+
#else
42+
#include <stdint.h> // for uint64_t
3743
#endif /* __cplusplus */
3844

39-
/// A pointer to a C++ pdal::capi::Pipeline object
45+
typedef struct PDALDimType PDALDimType;
46+
47+
struct PDALDimType
48+
{
49+
uint32_t id;
50+
uint32_t type;
51+
double scale;
52+
double offset;
53+
};
54+
55+
/// A pointer to a dimension type list
56+
typedef void* PDALDimTypeListPtr;
57+
58+
/// A pointer to a pipeline
4059
typedef void* PDALPipelinePtr;
4160

42-
/// A pointer to a C++ pdal::capi::PointView object
61+
/// An index to a point in a list
62+
typedef uint64_t PDALPointId;
63+
64+
/// A pointer to a point layout
65+
typedef void* PDALPointLayoutPtr;
66+
67+
/// A pointer to point view
4368
typedef void* PDALPointViewPtr;
4469

45-
/// A pointer to a C++ pdal::capi::PointViewCollection object
46-
typedef void* PDALPointViewCollectionPtr;
70+
/// A pointer to a point view iterator
71+
typedef void* PDALPointViewIteratorPtr;
4772

4873
#endif /* PDAL_CAPI_FORWARD_H */

source/pdal/capi/Pipeline.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
#include "Pipeline.h"
6-
#include "PointViewCollection.h"
6+
#include "PointViewIterator.h"
77

88
#include <pdal/PipelineExecutor.hpp>
99

@@ -172,18 +172,18 @@ namespace pdal
172172
return ptr && ptr->get() && ptr->get()->validate();
173173
}
174174

175-
PDALPointViewCollectionPtr PDALGetPointViews(PDALPipelinePtr pipeline)
175+
PDALPointViewIteratorPtr PDALGetPointViews(PDALPipelinePtr pipeline)
176176
{
177177
Pipeline *ptr = reinterpret_cast<Pipeline *>(pipeline);
178-
pdal::capi::PointViewCollection *views = nullptr;
178+
pdal::capi::PointViewIterator *views = nullptr;
179179

180180
if (ptr && ptr->get())
181181
{
182182
auto &v = ptr->get()->getManagerConst().views();
183183

184184
if (!v.empty())
185185
{
186-
views = new pdal::capi::PointViewCollection(v);
186+
views = new pdal::capi::PointViewIterator(v);
187187
}
188188
}
189189

0 commit comments

Comments
 (0)