[pdal] How to test if file was loaded successfully?

Vaclav Petras wenzeslaus at gmail.com
Wed Sep 2 17:36:19 PDT 2015


Hi,

any suggestions how should I test if a file was loaded successfully?
Example of code is in the porting guide I'm working on [1].

What was in the libLAS code I'm using is

    LASReaderH LAS_reader = LASReader_Create("somefile.las");
    LASHeaderH LAS_header = LASReader_GetHeader(LAS_reader);
    if (LAS_header == NULL)
        // fail with "Input file is not a LAS LiDAR point cloud"

Now I'm using (now check):

    std::unique_ptr<LasReader> las_reader(LasReader())

Somewhere in the PDAL source code I've seen:

    Stage *stage = factory.createStage(driver);
        if (!stage)
            // fail with "reader creation failed"

Later followed by (or any other appropriate pointer handling):

    std::unique_ptr<Stage>(s)

Is this the right approach to use in general with functions in PDAL
returning pointers? Can I use it with the LasReader()?

Are there any other things I should check for in this opening and reading
phase? Some typical error states? Wrong/unknow format? Or should I just
wrap this whole part in a big try-catch with pdal_error?

Thanks for suggestions,
Vaclav

[1]
https://github.com/wenzeslaus/PDAL/blob/liblas-to-pdal-transition/doc/tutorial/liblas_to_pdal.rst
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20150902/fabae6c3/attachment.html>


More information about the pdal mailing list