MCPcopy Create free account
hub / github.com/PDAL/PDAL / TEST

Function TEST

test/unit/filters/FaceRasterTest.cpp:48–106  ·  view source on GitHub ↗

NOTE: The test data has an accompanying jpg that depicts the points, their triangulation and the interesting barycentric calculation.

Source from the content-addressed store, hash-verified

46// NOTE: The test data has an accompanying jpg that depicts the points,
47// their triangulation and the interesting barycentric calculation.
48TEST(FaceRasterTest, basic)
49{
50 Options ro;
51 ro.add("filename", Support::datapath("filters/hagtest.txt"));
52
53 StageFactory factory;
54 Stage& r = *(factory.createStage("readers.text"));
55 r.setOptions(ro);
56
57 Options rngO;
58 rngO.add("limits", "Classification[2:2]");
59 Stage& rng = *(factory.createStage("filters.range"));
60 rng.setOptions(rngO);
61 rng.setInput(r);
62
63 Stage& d = *(factory.createStage("filters.delaunay"));
64 d.setInput(rng);
65
66 Options fo;
67 fo.add("resolution", 1);
68 Stage& f = *(factory.createStage("filters.faceraster"));
69 f.setInput(d);
70 f.setOptions(fo);
71
72 const std::string output_file = Support::temppath("test.tif");
73
74 Options wo;
75 wo.add("filename", output_file);
76 Stage& w = *(factory.createStage("writers.raster"));
77 w.setInput(f);
78 w.setOptions(wo);
79
80 PointTable t1;
81 w.prepare(t1);
82 PointViewSet s = w.execute(t1);
83 PointViewPtr v = *s.begin();
84
85 gdal::Raster raster(output_file, "GTiff");
86 if (raster.open() != gdal::GDALError::None)
87 throw pdal_error(raster.errorMsg());
88 std::vector<double> data;
89 raster.readBand(data, 1);
90 int row = 0;
91 int col = 0;
92
93 const std::vector<double> expected
94 {
95 -9999, 10, -9999, -9999, -9999, -9999,
96 -9999, 9, 7, -9999, -9999, -9999,
97 10, 8, 6, 4, -9999, -9999,
98 6.66667, 4.66667, 2.66667, 6, 7, -9999,
99 3.33333, 1.33333, 4.66667, 8, 9, 10,
100 0, 3.33333, 6.66667, 10, -9999, -9999
101 };
102
103 size_t size = raster.width() * raster.height();
104 for (size_t i = 0; i < size; ++i)
105 EXPECT_NEAR(expected[i], data[i], .00001);

Callers

nothing calls this directly

Calls 11

datapathFunction · 0.85
temppathFunction · 0.85
createStageMethod · 0.80
setOptionsMethod · 0.80
addMethod · 0.45
prepareMethod · 0.45
executeMethod · 0.45
beginMethod · 0.45
openMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected