Hello,<br><br>My work on liblas::Writer::WritePoint() was delayed by other tasks and I just resume it recently. <br><br>Now I implemented what we talked about (but with some small changes). I tested it and it worked in unit test. However, in real cases to use it, we still have two problems to solve. <br>
<br><br>First, to in-place update a point in LIDAR file, we need to know the absolute index of that point. However, currently liblas cannot provide this information. I thought I could use accumulated point count as the point's index when I read points one by one using ReadNextPoint(). But when liblas:Reader has filter(s), ReadNextPoint() only returns part of points but not whole point set.<br>
<br>To solve this problem, I think we can add a member variable, m_AbsoluteIndex, to liblas::Point. Then we can also store the absolute index of the point in liblas::detail::ReadNextPoint() . <br><br><br><br>Second, sometime we need read-writer besides reader and writer. For example, if the user changes some points and wants to update the changes to the LIDAR file and continue editing, without ReaderUpdater, the user need to store all the changes in the memory, close current reader, create a writer for the file, update the points, close the writer, then use the reader to open the file again. This procedure is not convenient, and memory consuming when large amount of points need to be changed. <br>
<br>To implement a ReaderUpdater (or ReaderWriter), I think we can do the following: <br><br>1.<br>Add ReaderUpdaterI in liblas.hpp: <br>class ReaderUpdaterI : public ReaderI<br>{<br>public:<br><br>        virtual bool OverwritePoint(const Point& point, std::size_t pointIndex) = 0;<br>
<br> virtual ~ReaderExI() {}<br><br>};<br><br>2. <br>Add a class, liblas:detail:ReaderUpdater <br><br>class liblias::detail::ReaderUpdater : public ReaderUpdaterI<br>{<br>public:<br>        bool OverwritePoint(liblas::Point const& point, std::size_t pointIndex);<br>
<br>private:<br> liblas::detail::Reader * m_reader; // or use shared pointer like ReaderPtr<br>}<br><br><br>3. <br>Of course, add class liblas::ReaderUpdater to wrap liblas::detail::ReaderUpdater<br><br><br>
How do you think of these changes? Will they break current design and/or other software that use liblas? <br><br>Thanks,<br>Hongwei Shen<br><br><br><br><br>On Fri, Jan 6, 2012 at 4:10 PM, Howard Butler <<a href="mailto:hobu.inc@gmail.com">hobu.inc@gmail.com</a>> wrote:<br>
> If you do work to add this, you'll probably just need to add a seek() method to the liblas::Writer class (and underlying implementation classes) that positions the stream. After that liblas::Writer::WritePoint() should overwrite the data, though you may want to do some header checks to make sure that the size in bytes of the point is the same as the size in bytes that the file is expecting -- otherwise you'd start clobbering data.<br>
><br>> On Jan 6, 2012, at 2:36 PM, Hongwei Shen wrote:<br>><br>>> Thank you for the answer, Howard.<br>>><br>>> I'll check if I can add this support.<br>>><br>>> Thanks,<br>>> Hongwei<br>
>><br>>><br>>> On Fri, Jan 6, 2012 at 1:47 PM, Howard Butler <<a href="mailto:hobu.inc@gmail.com">hobu.inc@gmail.com</a>> wrote:<br>>>><br>>>> On Jan 6, 2012, at 12:16 PM, Hongwei Shen wrote:<br>
>>><br>>>>> Hello,<br>>>>><br>>>>> The scenario is: the user opens a large Lidar file, changes the<br>>>>> classification labels of a small number of points and save the changes<br>
>>>> to the file. When the Lidar file is huge, it is time-consuming to<br>>>>> output all the points. So it would be better if only the modified<br>>>>> points are updated in the Lidar file. According to my understanding<br>
>>>> now, Liblas needs to save all the (changed and unchanged) points to a<br>>>>> new Lidar file. That's because Liblas can open a Lidar file either in<br>>>>> read-only mode or write-only mode, but not in read-write mode.<br>
>>>><br>>>>> Do I understand correctly? Is there a way to only update some points?<br>>>><br>>>><br>>>> Yes, your understanding is correct. libLAS does not support in-place updating of points.<br>
>>><br>>>> Howard<br>>>><br>><br><br>