[pdal] How to get las header info?
Mateusz Loskot
mateusz at loskot.net
Tue Jul 5 15:05:45 PDT 2022
On Tue, 5 Jul 2022 at 19:06, Peder Axensten <Peder.Axensten at slu.se> wrote:
>
> I tried that too. :-)
> I tried the following, inspired by code on https://pdal.io/api/transition/index.html:
>
> pdal::LasHeader get_header( const std::filesystem::path & path_ ) {
> pdal::Option las_opt( "filename", path_.native() );
> pdal::Options las_opts;
> las_opts.add( las_opt );
>
> pdal::PointTable table;
> pdal::LasReader las_reader;
> las_reader.setOptions( las_opts );
> las_reader.prepare( table );
>
> pdal::PointViewSet point_view_set = las_reader.execute( table );
> pdal::PointViewPtr point_view = *point_view_set.begin();
> pdal::Dimension::IdList dims = point_view->dims();
> return las_reader.header();
You observe garbage header because it actually is destroyed at exit
from get_header.
You must keep LasReader object alive for as long as you refer to its
LasHeader object.
The LasHeader is NOT a value type, but a thin 'view' over internal object.
The bug in your code is somewhat equivalent to this
auto foo()
{
std::vector<int> v;
return v.begin();
}
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
More information about the pdal
mailing list