PDAL / PDAL

PDAL is Point Data Abstraction Library. GDAL for point cloud data.

Home Page:https://pdal.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PipelineManager stages emit empty metadata in C++ API?

Tychonoff-Space opened this issue · comments

I am trying to integrate the PDAL library into my C++ project, and I have managed to read in and extract point data successfully from some example LAS files. It is my understanding that the LAS header contains some information about data extents (e.g. minimum and maximum values and offsets for each dimension) and that filters can be used to compute additional statistics (e.g. means, medians, etc). I cannot figure out how to actually extract/compute any of this data using the C++ API however.

Here is some code I tried to use to compute statistics using the filters.stats driver on a LAS file, but the metadata appears to be empty:

    pdal::PipelineManager manager;
    std::string extension = getFileExtension(filename);
    std::string reader = "readers."+extension;
    manager.makeReader(filename.c_str(),reader);
    manager.makeFilter("filters.stats");
    manager.execute();
    const pdal::PointViewSet& viewSet = manager.views();
    auto stages = manager.stages();
    for (auto stage : stages) {
        auto stage_name = stage->getName();
        printf(stage_name.c_str());
        auto metadata = stage->getMetadata();
        auto json = metadata.jsonValue();
        printf(json.c_str());
    }

The stage names print (readers.las, filters.stats), but the json views of the metadata are empty. Is this an incorrect way of going about what I am trying to accomplish? If so what is the proper way to do it? A minimal working example would be extremely helpful.

If you want to print the entire metadata tree as json, call pdal::Utils::toJSON(metadata) instead of metadata.jsonValue().