Skip to content

Commit 9928768

Browse files
committed
Merge branch 'unity-compatibility' into 'master'
Enable Unity compatibility See merge request nublar/pdal-c!8
2 parents 36dbb61 + cb2a362 commit 9928768

17 files changed

+366
-1048
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Ignore files generated by CMake from a file template
22
tests/pdal-stats.las
33
tests/data/*.json
4-
tests/pdal/capi/*Test.c
4+
tests/pdal/test_pdalc_*.c
55

66
# Ignore doxygen docs
77
/doc/doxygen

.gitlab-ci.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ build-x64-windows-debug:
6262
.job_template: &test-windows
6363
tags:
6464
- windows
65+
before_script:
66+
- set GDAL_DATA=%VCPKG_ROOT%\installed\x64-windows\share\gdal
67+
- set PROJ_LIB=%VCPKG_ROOT%\installed\x64-windows\share\proj4
6568
stage: test
6669
cache:
6770
policy: pull
@@ -70,11 +73,8 @@ test-x64-windows-release:
7073
<<: *test-windows
7174
dependencies:
7275
- build-x64-windows-release
73-
before_script:
74-
- cd %VCPKG_ROOT%/installed/x64-windows/bin
7576
script:
76-
- set GDAL_DATA=%VCPKG_ROOT%\installed\x64-windows\share\gdal
77-
- set PROJ_LIB=%VCPKG_ROOT%\installed\x64-windows\share\proj4
77+
- cd %VCPKG_ROOT%/installed/x64-windows/bin
7878
- copy proj_4_9.dll proj.dll
7979
- "%CI_PROJECT_DIR%/build/build-x64-windows-release/bin/test_pdalc"
8080
cache:
@@ -86,11 +86,8 @@ test-x64-windows-debug:
8686
<<: *test-windows
8787
dependencies:
8888
- build-x64-windows-debug
89-
before_script:
90-
- cd %VCPKG_ROOT%/installed/x64-windows/debug/bin
9189
script:
92-
- set GDAL_DATA=%VCPKG_ROOT%\installed\x64-windows\share\gdal
93-
- set PROJ_LIB=%VCPKG_ROOT%\installed\x64-windows\share\proj4
90+
- cd %VCPKG_ROOT%/installed/x64-windows/debug/bin
9491
- copy proj_4_9_d.dll proj.dll
9592
- "%CI_PROJECT_DIR%/build/build-x64-windows-debug/bin/test_pdalcd"
9693
cache:

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
3636
set(COVERAGE_EXCLUDES
3737
'build/*'
3838
'cmake/*'
39-
'tests/*'
40-
'tests/pdal/capi/*'
39+
'tests/pdal/*'
4140
'/usr/include/*'
4241
)
4342
endif()

source/pdal/pdalc_config.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,92 @@
55
#include "pdalc_config.h"
66

77
#include <pdal/pdal_config.hpp>
8+
#include <pdal/util/Utils.hpp>
89

10+
#include <cstdlib>
911
#include <cstring>
1012
#include <string>
1113

1214
namespace pdal
1315
{
1416
namespace capi
1517
{
18+
size_t PDALGetGdalDataPath(char *path, size_t size)
19+
{
20+
size_t length = 0;
21+
22+
if (path && size > 0)
23+
{
24+
path[0] = '\0';
25+
path[size-1] = '\0';
26+
27+
char *env = nullptr;
28+
29+
try
30+
{
31+
env = std::getenv("GDAL_DATA");
32+
}
33+
catch (const std::exception &)
34+
{
35+
env = nullptr;
36+
}
37+
38+
if (env)
39+
{
40+
std::strncpy(path, env, size - 1);
41+
length = std::min(std::strlen(env), size - 1);
42+
}
43+
}
44+
45+
return length;
46+
}
47+
48+
size_t PDALGetProj4DataPath(char *path, size_t size)
49+
{
50+
size_t length = 0;
51+
52+
if (path && size > 0)
53+
{
54+
path[0] = '\0';
55+
path[size-1] = '\0';
56+
57+
char *env = nullptr;
58+
59+
try
60+
{
61+
env = std::getenv("PROJ_LIB");
62+
}
63+
catch (const std::exception &)
64+
{
65+
env = nullptr;
66+
}
67+
68+
if (env)
69+
{
70+
std::strncpy(path, env, size - 1);
71+
length = std::min(std::strlen(env), size - 1);
72+
}
73+
}
74+
75+
return length;
76+
}
77+
78+
void PDALSetGdalDataPath(const char *path)
79+
{
80+
if (path)
81+
{
82+
pdal::Utils::setenv("GDAL_DATA", path);
83+
}
84+
}
85+
86+
void PDALSetProj4DataPath(const char *path)
87+
{
88+
if (path)
89+
{
90+
pdal::Utils::setenv("PROJ_LIB", path);
91+
}
92+
}
93+
1694
size_t PDALFullVersionString(char *version, size_t size)
1795
{
1896
size_t length = 0;

source/pdal/pdalc_config.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,38 @@ namespace pdal
2323
#else
2424
#include <stdbool.h>
2525
#endif
26+
/**
27+
* Retrieves the path to the GDAL data directory.
28+
*
29+
* @param[out] path The buffer used to retrieve the path
30+
* @param size The size of the provided buffer
31+
* @return The size of the retrieved path
32+
*/
33+
PDALC_API size_t PDALGetGdalDataPath(char *path, size_t size);
34+
35+
/**
36+
* Retrieves the path to the proj4 data directory.
37+
*
38+
* @param[out] path The buffer used to retrieve the path
39+
* @param size The size of the provided buffer
40+
* @return The size of the retrieved path
41+
*/
42+
PDALC_API size_t PDALGetProj4DataPath(char *path, size_t size);
43+
44+
/**
45+
* Sets the path to the GDAL data directory.
46+
*
47+
* @param path The path to set
48+
*/
49+
PDALC_API void PDALSetGdalDataPath(const char *path);
50+
51+
/**
52+
* Sets the path to the proj4 data directory.
53+
*
54+
* @param path The path to set
55+
*/
56+
PDALC_API void PDALSetProj4DataPath(const char *path);
57+
2658
/**
2759
* Retrieves the full PDAL version string.
2860
* The full version string includes the major version number, the minor version
@@ -66,7 +98,7 @@ namespace pdal
6698
*
6799
* @see pdal::config::sha1
68100
*
69-
* @param[out] version The buffer used to retrieve the SHA1 string
101+
* @param[out] sha1 The buffer used to retrieve the SHA1 string
70102
* @param size The size of the provided buffer
71103
* @return The size of the retrieved SHA1 string
72104
*/
@@ -104,7 +136,7 @@ namespace pdal
104136
*
105137
* @see pdal::config::debugInformation
106138
*
107-
* @param[out] version The buffer used to retrieve the debugging information
139+
* @param[out] info The buffer used to retrieve the debugging information
108140
* @param size The size of the provided buffer
109141
* @return The size of the retrieved debugging information
110142
*/
@@ -115,7 +147,7 @@ namespace pdal
115147
*
116148
* @see pdal::config::pluginInstallPath
117149
*
118-
* @param[out] version The buffer used to retrieve the installation path
150+
* @param[out] path The buffer used to retrieve the installation path
119151
* @param size The size of the provided buffer
120152
* @return The size of the retrieved installation path
121153
*/

source/pdal/pdalc_dimtype.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ namespace pdal
3131
return size;
3232
}
3333

34+
uint64_t PDALGetDimTypeListByteCount(PDALDimTypeListPtr types)
35+
{
36+
uint64_t byteCount = 0;
37+
size_t pointCount = PDALGetDimTypeListSize(types);
38+
39+
for (size_t i = 0; i < pointCount; ++i)
40+
{
41+
byteCount += PDALGetDimTypeInterpretationByteCount(PDALGetDimType(types, i));
42+
}
43+
44+
return byteCount;
45+
}
46+
3447
PDALDimType PDALGetInvalidDimType()
3548
{
3649
PDALDimType dim ={
@@ -71,15 +84,16 @@ namespace pdal
7184
return result;
7285
}
7386

87+
size_t PDALGetDimTypeInterpretationByteCount(PDALDimType dim)
88+
{
89+
return pdal::Dimension::size(static_cast<pdal::Dimension::Type>(dim.type));
90+
}
91+
7492
PDALDimType PDALGetDimType(PDALDimTypeListPtr types, size_t index)
7593
{
7694
pdal::capi::DimTypeList *wrapper = reinterpret_cast<pdal::capi::DimTypeList *>(types);
7795

7896
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-
// };
8397

8498
if (wrapper && wrapper->get())
8599
{

source/pdal/pdalc_dimtype.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ namespace pdal
2929
*/
3030
PDALC_API size_t PDALGetDimTypeListSize(PDALDimTypeListPtr types);
3131

32+
/**
33+
* Returns the number of bytes required to store data referenced
34+
* by a dimension type list.
35+
*
36+
* @param types A pointer to the dimension type list
37+
* @return The number of bytes required to store the referenced data
38+
*/
39+
PDALC_API uint64_t PDALGetDimTypeListByteCount(PDALDimTypeListPtr types);
40+
3241
/**
3342
* Returns the invalid dimension type. This dimension type has:
3443
* - An ID value of 0 that corresponds to pdal::Dimension::Id::Unknown
@@ -72,6 +81,14 @@ namespace pdal
7281
*/
7382
PDALC_API size_t PDALGetDimTypeInterpretationName(PDALDimType dim, char *name, size_t size);
7483

84+
/**
85+
* Retrieves the byte count of a dimension type's interpretation, i.e., its data size.
86+
*
87+
* @param dim The dimension type
88+
* @return The byte count of the retrieved interpretation
89+
*/
90+
PDALC_API size_t PDALGetDimTypeInterpretationByteCount(PDALDimType dim);
91+
7592
/**
7693
* Disposes the provided dimension type list.
7794
*

0 commit comments

Comments
 (0)