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

Method classCounts

test/unit/filters/GroundFilterTest.cpp:49–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47{
48 protected:
49 std::unordered_map<uint8_t, size_t> classCounts(
50 const std::string filterTypeName,
51 const uint8_t groundClass,
52 const uint8_t otherClass,
53 const uint8_t startingClass,
54 const bool onlyGround
55 )
56 {
57 StageFactory f;
58
59 Stage* reader(f.createStage("readers.las"));
60 Options rOpts;
61 rOpts.add("filename", Support::datapath("las/warsaw_small.las"));
62 reader->setOptions(rOpts);
63
64 Stage* assign(f.createStage("filters.assign"));
65 Options aOpts;
66 aOpts.add("assignment", "Classification[:]=" + std::to_string(startingClass));
67 assign->setInput(*reader);
68 assign->setOptions(aOpts);
69
70 const std::string filterType = "filters." + filterTypeName;
71 Stage* filter(f.createStage(filterType));
72 Options fOpts;
73 fOpts.add("ground_class", groundClass);
74 fOpts.add("other_class", otherClass);
75 fOpts.add("only_ground", onlyGround);
76 filter->setInput(*assign);
77 filter->setOptions(fOpts);
78
79 PointTable t;
80 filter->prepare(t);
81 PointViewSet s = filter->execute(t);
82
83 PointViewPtr v = *s.begin();
84
85 std::unordered_map<uint8_t, size_t> classCounts;
86 for (PointId id = 0; id < v->size(); ++id)
87 {
88 uint8_t cl = v->getFieldAs<uint8_t>(Dimension::Id::Classification, id);
89 classCounts[cl]++;
90 }
91 return classCounts;
92 }
93};
94
95TEST_P(CustomGroundClassTest, CustomGroundClass)

Callers 1

TEST_PFunction · 0.80

Calls 9

datapathFunction · 0.85
createStageMethod · 0.80
setOptionsMethod · 0.80
filterFunction · 0.50
addMethod · 0.45
prepareMethod · 0.45
executeMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected