[Liblas-devel] Can Liblas only update a small portion of the points in Lidar file?

Hongwei Shen henryshen.cn at gmail.com
Wed Feb 8 13:41:02 EST 2012


Hello,

My work on liblas::Writer::WritePoint() was delayed by other tasks and I
just resume it recently.

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.


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.

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() .



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.

To implement a ReaderUpdater (or ReaderWriter),  I think we can do the
following:

1.
Add ReaderUpdaterI  in liblas.hpp:
class ReaderUpdaterI : public ReaderI
{
public:

virtual bool OverwritePoint(const Point& point, std::size_t pointIndex) = 0;

   virtual ~ReaderExI() {}

};

2.
Add a class, liblas:detail:ReaderUpdater

class liblias::detail::ReaderUpdater : public ReaderUpdaterI
{
public:
bool OverwritePoint(liblas::Point const& point, std::size_t pointIndex);

private:
      liblas::detail::Reader  *  m_reader;    // or use shared pointer
 like ReaderPtr
}


3.
Of course,  add class liblas::ReaderUpdater  to wrap
liblas::detail::ReaderUpdater


How do you think of these changes?  Will they break current design and/or
other software that use liblas?

Thanks,
Hongwei Shen




On Fri, Jan 6, 2012 at 4:10 PM, Howard Butler <hobu.inc at gmail.com> wrote:
> 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.
>
> On Jan 6, 2012, at 2:36 PM, Hongwei Shen wrote:
>
>> Thank you for the answer, Howard.
>>
>> I'll check if I can add this support.
>>
>> Thanks,
>> Hongwei
>>
>>
>> On Fri, Jan 6, 2012 at 1:47 PM, Howard Butler <hobu.inc at gmail.com> wrote:
>>>
>>> On Jan 6, 2012, at 12:16 PM, Hongwei Shen wrote:
>>>
>>>> Hello,
>>>>
>>>> The scenario is: the user opens a large Lidar file,  changes the
>>>> classification labels of a small number of points and save the changes
>>>> to the file.  When the Lidar file is huge, it is time-consuming to
>>>> output all the points. So it would be better if only the modified
>>>> points are updated in the Lidar file.  According to my understanding
>>>> now, Liblas needs to save  all the (changed and unchanged) points to a
>>>> new Lidar file. That's because Liblas can open a Lidar file either in
>>>> read-only mode or write-only mode, but not in read-write mode.
>>>>
>>>> Do I understand correctly?  Is there a way to only update some points?
>>>
>>>
>>> Yes, your understanding is correct. libLAS does not support in-place
updating of points.
>>>
>>> Howard
>>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/liblas-devel/attachments/20120208/1a7eca87/attachment.html


More information about the Liblas-devel mailing list