[Liblas-devel] Fix for the bug that liblas cannot open some Lidar files

Hongwei Shen henryshen.cn at gmail.com
Wed Oct 5 13:38:22 EDT 2011


Hello,  Folks,

Recently I couldn't open some Lidar (.las) files using liblas. I
debugged for the problem and changed two lines of codes fix it.

I changed line  362 and 363 in liblas\1.7.0b\src\detail\reader\header.cpp :
        vlr.SetUserId(std::string(vlrh.userId));
        vlr.SetDescription(std::string(vlrh.description));

The above two lines should be changed to:
        vlr.SetUserId(std::string(vlrh.userId, 16)); // Length of
userId is 16 in the header
        vlr.SetDescription(std::string(vlrh.description, 32)); //
Length of userId is 32 in the header

The problem is ---  Header::ReadVLRs() assumes “user_id” and
“description”  are null-terminating string in the header of lidar
file, which is not always true.  For example, some Lidar files use
blank spaces at the end of real "user_id" to fill a length of 16
bytes.

I could be able to open these Lidar files using liblas after I changed
the code.


I don't know how to change source code of liblas or submit bugs
online.  So I'm sending this email.   Can someone integrate my changes
into liblas code?

Thanks,
Hongwei Shen
Software Engineering Intern, Erdas LPS team,


More information about the Liblas-devel mailing list