I try to use LASlib to insert crs-information in the header of a transformed LAS-file. To do this I need to insert some VLR in the header.
I use this code:
U8* data = new U8[32];
memset(data,0,32);
strncpy((char*)data, "EPSG::25832", 32);
lasreader->header.add_vlr("LASF_Projection", 34735, 32, data);
laswriter->update_header(&lasreader->header, TRUE, TRUE);
It compiles and runs without errors, but the resulting LAS-file does not have any VLR in the header.
I do not fully understand the sourcecode of LASlib, but I think there may be an error in LASwriterLAS::update_header:
…
if (update_extra_bytes)
{
if (header == 0)
{
fprintf(stderr,"ERROR: header pointer is zero\n");
return FALSE;
}
if (header->number_extra_attributes)
{
I64 start = header_start_position + header->header_size;
for (i = 0; i < (I32)header->number_of_variable_length_records; i++)
{
Perhaps the yellow number_extra_attributes should have been changed to number_of_variable_length_records?
Andreas
--
Download LAStools at
http://lastools.org/
Visit the LAStools group at
http://groups.google.com/group/lastools/
Be social with LAStools at
http://www.facebook.com/LAStools
http://www.twitter.com/LAStools