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

Method execute

kernels/EvalKernel.cpp:91–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91int EvalKernel::execute()
92{
93 ColumnPointTable predictedTable;
94 PointViewPtr predictedView = loadSet(m_predictedFile, predictedTable);
95 PointLayoutPtr predictedLayout(predictedTable.layout());
96 m_predictedDimId = predictedLayout->findDim(m_predictedDimName);
97 if (m_predictedDimId == Dimension::Id::Unknown)
98 throw pdal_error("Predicted dimension '" + m_predictedDimName +
99 "' does not exist.");
100
101 ColumnPointTable truthTable;
102 PointViewPtr truthView = loadSet(m_truthFile, truthTable);
103 PointLayoutPtr truthLayout(truthTable.layout());
104 m_truthDimId = truthLayout->findDim(m_truthDimName);
105 if (m_truthDimId == Dimension::Id::Unknown)
106 throw pdal_error("Truth dimension '" + m_truthDimName +
107 "' does not exist.");
108
109 assert(predictedView->size() == truthView->size());
110
111 KD3Index& kdi = truthView->build3dIndex();
112
113 int dim = m_labelStrList.size();
114
115 std::vector<int> labelList;
116 for (auto const& label : m_labelStrList)
117 labelList.push_back(std::stoi(label));
118 std::sort(labelList.begin(), labelList.end());
119
120 LabelStats ls(dim);
121
122 for (PointRef p : *predictedView)
123 {
124 // It would be nice if we could expect that the points are aligned in
125 // both the predicted and truth views, but this often cannot be
126 // guaranteed, so rather than using the same PointId, we search for the
127 // nearest neighbor.
128 PointId qid = kdi.neighbor(p);
129 PointRef q = truthView->point(qid);
130
131 // TODO (chambbj): We should perhaps look at the distance to the
132 // nearest point and reject or otherwise report distances greater than
133 // 0.0, indicating some sort of mismatch between files.
134
135 int pc = p.getFieldAs<int>(m_predictedDimId);
136 int qc = q.getFieldAs<int>(m_truthDimId);
137
138 auto it = std::find(labelList.begin(), labelList.end(), qc);
139 size_t qci;
140 if (it != labelList.end())
141 qci = std::distance(labelList.begin(), it);
142 else
143 qci = dim;
144
145 it = std::find(labelList.begin(), labelList.end(), pc);
146 size_t pci;
147 if (it != labelList.end())
148 pci = std::distance(labelList.begin(), it);

Callers 1

loadSetMethod · 0.45

Calls 11

findFunction · 0.85
fullVersionStringFunction · 0.85
toJSONFunction · 0.85
neighborMethod · 0.80
pointMethod · 0.80
findDimMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected