[pdal] How to add filters (with C++ API)
Odd Ragnar Lydersen
Odd-Ragnar.Lydersen at powel.no
Wed May 16 06:06:14 PDT 2018
I'm writing code to add filters when reading las files.
All examples are in json format, and I'm wondering what is the best way to do this in C++.
I've been looking at the tests from the source code, to get examples, but I can't find any that combine different kinds of filters.
Code example (Semi Pseudo):
if (useFilters)
{
bool filterInputIsSet = false;
LasReader filterReader;
prepareLasReader(filterReader, fileName);
if (useCropFilter)
{
cropOptions.add("bounds", someBounds);
if (!filterInputIsSet)
{
crpFilter.setInput(filterReader);
filterInputIsSet = true;
}
cropFilter.addOptions(cropOptions);
}
if (useClassFilter)
{
std::string classFilterString;
for (int i=0; i <= ClassificationType::eOverlapPoints; i++)
{
addClassToString(classFilterString);
}
rangeOptions.add("limits", classFilterString);
if (!filterInputIsSet) // Only rangeFilter is used
{
rangeFilter.setInput(filterReader);
filterInputIsSet = true;
}
else // Both filters are used
{
rngFilter.setInput(cropFilter);
}
rangeFilter.setOptions(rangeOptions);
rangeFilter.prepare(table);
point_view_set = rangeFilter.execute(table);
point_view = *point_view_set.begin();
}
else // Only cropFilter is used
{
cropFilter.prepare(table);
point_view_set = cropFilter.execute(table);
point_view = *point_view_set.begin();
}
}
else // No filters are used
{
LasReader.prepare(table);
point_view_set = LasReader.execute(table);
point_view = *point_view_set.begin();
}
Is there a better, and more elegant way to do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20180516/f75f130e/attachment-0001.html>
More information about the pdal
mailing list