[Liblas-devel] Re: Appending to files with LASWriter

Mateusz Loskot mateusz at loskot.net
Fri Feb 29 23:25:22 EST 2008


Howard Butler wrote:
> Mateusz,
> 
> I have implemented a modified version that behaves as follows for 
> WriterImpl and LASFile:
> 
> 1) If the file is opened for write (eWrite in LASFile, which has mode 
> std::ios::out | std::ios::binary), the existing overwriting behavior is 
> preserved.

OK

> 2) If the file is opened for append (eAppend in LASFile, which has mode 
> std::ios::out | std::ios::in | std::ios::binary), we seek to the end and 
> to the beginning of the file to determine how long it is, subtract the 
> header, and then divide by the data record length to determine how many 
> points (m_pointCount) the WriterImpl has.

OK, the idea sounds good to me.

>  Then, at the end of 
> WriteHeader, if we have m_pointCount, seek to the end of the file so we 
> can start writing, otherwise, leave it where it is. IMO, we can't 
> necessarily believe the header's point count, and while the seeking may 
> have a cost, this approach allows us to determine the number of points 
> without actually reading all of them.

Yes, I think you are right.
However, we will need to monitor potential problems and collect 
observations from users. So, we can see what % of headers are broken
and if it's very common or rare situation.

> 3) Added eAppend to LASFile and modified the FileImpl to take in a mode 
> which it uses to determine the openmode to use.

OK, works for me.

> 4) Modified all of the calls to LASFile to set the mode in the constructor.
> 
> http://liblas.org/changeset/478

OK

Greetings
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Liblas-devel mailing list