[pdal] How to add filters (with C++ API)
Andrew Bell
andrew.bell.ia at gmail.com
Wed May 16 07:56:30 PDT 2018
I'm not exactly sure what your goal is. If you're trying to write some
kind of a UI that builds a pipeline based on some options (or some such),
then what you're doing is pretty much it. You might want to look at the
source code for some of the kernels. The info kernel is a bit of a mess,
but does this kind of thing. You might also have a look at
PipelineManager, which is what we use internally to build pipelines from a
specification.
That said, no matter what you're doing, the general procedure is to build a
pipeline, then prepare and execute it.
Hope that helps,
On Wed, May 16, 2018 at 9:06 AM, Odd Ragnar Lydersen <
Odd-Ragnar.Lydersen at powel.no> wrote:
> 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?
>
>
>
> _______________________________________________
> pdal mailing list
> pdal at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/pdal
>
--
Andrew Bell
andrew.bell.ia at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20180516/de4a889f/attachment-0001.html>
More information about the pdal
mailing list