Skip to content

Commit 5cca1d5

Browse files
committed
Enable PointView projection string unit tests
- Added new pipelines that enable projection string retrieval - Set GDAL_DATA and PROJ_LIB environment variables for Windows tests
1 parent 1418cb0 commit 5cca1d5

File tree

7 files changed

+123
-14
lines changed

7 files changed

+123
-14
lines changed

.gitlab-ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ 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
7678
- "%CI_PROJECT_DIR%/build/build-x64-windows-release/bin/test_pdal_c"
7779
cache:
7880
key: build-x64-windows-release
@@ -86,7 +88,9 @@ test-x64-windows-debug:
8688
before_script:
8789
- cd %VCPKG_ROOT%/installed/x64-windows/debug/bin
8890
script:
89-
- "%CI_PROJECT_DIR%/build/build-x64-windows-debug/bin/test_pdal_cd"
91+
- set GDAL_DATA=%VCPKG_ROOT%\installed\x64-windows\share\gdal
92+
- set PROJ_LIB=%VCPKG_ROOT%\installed\x64-windows\share\proj4
93+
- "%CI_PROJECT_DIR%/build/build-x64-windows-debug/bin/test_pdal_cd"
9094
cache:
9195
key: build-x64-windows-debug
9296
paths:

.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
}

source/pdal/capi/PointView.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,78 @@ namespace pdal
1818
#include <stdbool.h> // for bool
1919
#include <stdint.h> // for uint64_t
2020
#endif
21+
/**
22+
* Disposes the provided point `view`.
23+
*
24+
* @param view The point view to dispose
25+
*/
2126
PDAL_C_API void PDALDisposePointView(PDALPointViewPtr view);
2227

28+
/**
29+
* Returns the ID of the provided point `view`.
30+
*
31+
* @see pdal::PointView::id
32+
*
33+
* @param view The point view
34+
* @return The view's ID
35+
*/
2336
PDAL_C_API int PDALGetPointViewId(PDALPointViewPtr view);
2437

38+
/**
39+
* Returns the number of points in the provided `view`.
40+
*
41+
* @see pdal::PointView::size
42+
*
43+
* @param view The point view
44+
* @return The number of points
45+
*/
2546
PDAL_C_API uint64_t PDALGetPointViewSize(PDALPointViewPtr view);
2647

48+
/**
49+
* Returns whether the provided point `view` is empty, i.e., has no points.
50+
*
51+
* @see pdal::PointView::empty
52+
*
53+
* @param view The point view
54+
* @return Whether the point view is empty
55+
*/
2756
PDAL_C_API bool PDALIsPointViewEmpty(PDALPointViewPtr view);
57+
2858
/**
59+
* Clones the provided point `view`.
60+
*
2961
* @see pdal::PointView::makeNew
62+
*
63+
* @param view The original point view
64+
* @return A pointer to the new point view
3065
*/
3166
PDAL_C_API PDALPointViewPtr PDALClonePointView(PDALPointViewPtr view);
3267

68+
/**
69+
* Returns the proj4 projection string for the provided point `view`.
70+
*
71+
* @see pdal::PointView::spatialReference
72+
*
73+
* @param view The point view
74+
* @param[out] proj The buffer used to hold the resulting proj4 projection string
75+
* @param size The size of the proj4 projection string buffer
76+
* @return The size of the resulting proj4 projection string
77+
*/
3378
PDAL_C_API size_t PDALGetPointViewProj4(PDALPointViewPtr view, char *proj, size_t size);
3479

80+
/**
81+
* Returns the Well-Known Text (WKT) projection string for the provided point `view`.
82+
* @see pdal::PointView::spatialReference
83+
*
84+
* @param view The point view
85+
* @param[out] wkt The buffer used to hold the resulting WKT projection string
86+
* @param size The size of the wkt projection string buffer
87+
* @param pretty Whether to enhance the formatting of the resulting WKT string
88+
* @return The size of the resulting WKT projection string
89+
*/
3590
PDAL_C_API size_t PDALGetPointViewWkt(PDALPointViewPtr view, char *wkt, size_t size, bool pretty);
3691

92+
//! PDAL_C_API PDALPointLayoutPtr PDALGetPointViewLayout(PDALPointViewPtr view);
3793

3894
/**
3995
* Fill a buffer with point data specified by the dimension list.
@@ -42,10 +98,19 @@ namespace pdal
4298
* @param idx Index of point to get.
4399
* @param[out] buf Pointer to buffer to fill.
44100
*/
101+
//! PDAL_C_API void getPackedPoint(const DimTypeList& dims, PointId idx, char *buf);
45102

103+
//! PDAL_C_API void getPackedPoints(const DimTypeList& dims, PointId idx, char *buf);
46104

47105
/**
106+
* Fill a buffer with point data specified by the dimension list, accounts index
107+
* Using this functions it is possible to pack all points into one buffer
108+
* @param pv PointView pointer.
109+
* @param dims List of dimensions/types to retrieve.
110+
* @param idx Index of point to get.
111+
* @param buf Pointer to buffer to fill
48112
*/
113+
//! PDAL_C_API void appendPackedPoint(PointViewPtr pv, const DimTypeList& dims, PointId idx, std::size_t pointSize, char *buf)
49114

50115
#ifdef __cplusplus
51116
}

tests/data/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
set(PIPELINES
2+
simple-reproject.json
3+
sort.json
24
stats.json
35
)
46

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"pipeline":[
3+
{
4+
"filename": "@CMAKE_SOURCE_DIR@/tests/data/las/1.2-with-color.las",
5+
"spatialreference": "EPSG:2993"
6+
},
7+
{
8+
"type": "filters.reprojection",
9+
"out_srs": "EPSG:4326"
10+
}
11+
]
12+
}

tests/data/sort.json.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"pipeline": [
3+
"@CMAKE_SOURCE_DIR@/test/data/las/1.2-with-color.las",
4+
{
5+
"type": "filters.sort",
6+
"dimension": "X"
7+
}
8+
]
9+
}

tests/pdal/capi/PointViewTest.c.in

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static PDALPointViewCollectionPtr gPointViewCollection = NULL;
6262

6363
static void setupPointViewTest(void *arg)
6464
{
65-
FILE *file = fopen("@CMAKE_BINARY_DIR@//data/stats.json", "rb");
65+
FILE *file = fopen("@CMAKE_BINARY_DIR@/data/simple-reproject.json", "rb");
6666
char *json = NULL;
6767

6868
if (file)
@@ -76,7 +76,6 @@ static void setupPointViewTest(void *arg)
7676
{
7777
fread(json, 1, length, file);
7878
json[length] = '\0';
79-
8079
gPipeline = PDALCreatePipeline(json);
8180

8281
if (gPipeline && PDALExecutePipeline(gPipeline))
@@ -170,11 +169,10 @@ TEST testPDALGetPointViewProj4(void)
170169
size = PDALGetPointViewProj4(view, proj, 0);
171170
ASSERT_FALSE(size > 0);
172171

173-
// TODO Enable when test incorporates a pipeline with projection info
174-
// size = PDALGetPointViewProj4(view, proj, 1024);
175-
// ASSERT_FALSE(size == 0 || size > 1024);
176-
// ASSERT_FALSE(proj[0] == '\0');
177-
// printf("\n%s\n", proj);
172+
size = PDALGetPointViewProj4(view, proj, 1024);
173+
ASSERT_FALSE(size == 0 || size > 1024);
174+
ASSERT_FALSE(proj[0] == '\0');
175+
ASSERT_STR_EQ("+proj=longlat +datum=WGS84 +no_defs", proj);
178176

179177
PASS();
180178
}
@@ -199,11 +197,21 @@ TEST testPDALGetPointViewWkt(void)
199197
size = PDALGetPointViewWkt(view, wkt, 0, false);
200198
ASSERT_FALSE(size > 0);
201199

202-
// TODO Enable when test incorporates a pipeline with projection info
203-
// size = PDALGetPointViewWkt(view, wkt, 1024, false);
204-
// ASSERT_FALSE(size == 0 || size > 1024);
205-
// ASSERT_FALSE(wkt[0] == '\0');
206-
// printf("\n%s\n", wkt);
200+
size = PDALGetPointViewWkt(view, wkt, 1024, false);
201+
ASSERT_FALSE(size == 0 || size > 1024);
202+
ASSERT_FALSE(wkt[0] == '\0');
203+
ASSERT_STR_EQ(
204+
"GEOGCS[\"WGS 84\","
205+
"DATUM[\"WGS_1984\","
206+
"SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],"
207+
"AUTHORITY[\"EPSG\",\"6326\"]"
208+
"],"
209+
"PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],"
210+
"UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],"
211+
"AUTHORITY[\"EPSG\",\"4326\"]"
212+
"]",
213+
wkt
214+
);
207215

208216
PASS();
209217
}

0 commit comments

Comments
 (0)