[Liblas-devel] Bug?: problem copying file with offset

Howard Butler hobu.inc at gmail.com
Wed Mar 23 09:34:02 EDT 2011


On Mar 23, 2011, at 4:41 AM, Peder Axensten wrote:

> Thanks, Howard! I've implemented the temporary fix and I'll file the bug.
> 
> I've noticed that I have to update the x/y/z min/max information in the file's header myself. As long as I add points to a file, it would be very convenient and probably more efficient if the liblas::Writer did this for me. Actually, I have a wrapper for Writer only to handle this...

There is something called a CoordinateSummary in <liblas/utilty.hpp> that you can use to cumulate these statistics.  It can also be set on the reader as a filter using Reader::SetFilters() with others.  If you put it at the end of the filter list, it would only add points to the summary that pass all of the other filters.  Make sense?

After you've read through the points, you can do the following pseudo code to update the header:

close writer
open new reader
fetch header from reader
close reader
update header with summary info
open writer in append mode with header
writer->WriteHeader
close writer.


> 
> I understand that in the case I remove points, I'd need to update this information myself, since it can't be made automagically in a reasonable way.
> But then, the best way of removing points would be to copy the file while filtering it?
> 
> What is your view on this?
> 
> Best regards,
> 
> Peder
> 
> 
> 
> On 22 mar 2011, at 17.38, Howard Butler wrote:
> 
>> On Mar 20, 2011, at 10:57 AM, Peder Axensten wrote:
>> 
>>> I have a las-file with non-zero offsets (attached below).
>>> 
>>> If I used the code below to copy this file to a las-file I "lose" the offset. 
>> 
>> This is a bug. The points being read need to be rescaled before you write them.  I suspect in the compressed case, this is magically done for you.
>> 
>> Here's an inelegant stop gap.  Please file a bug and I will try to have the writer know when the data should be rescaled.
>> 
>> liblas::HeaderPtr hdr = liblas::HeaderPtr(new liblas::Header());
>> hdr->SetCompressed(compressed);
>> liblas::Writer			writer( ofs, *hdr );
>> ...
>> 
>> 				while( reader.ReadNextPoint() ) {
>> 					liblas::Point p = reader.GetPoint();
>> 					p.SetHeaderPtr(hdr);
>> 					++count;
>> 					writer.WritePoint( reader.GetPoint() );
>> 				}
>> 
>>> 
>> 
> 



More information about the Liblas-devel mailing list