[Liblas-devel] liblas problems

Mateusz Loskot mateusz at loskot.net
Tue Oct 28 06:07:40 EDT 2008


Howard Butler pisze:
> On Oct 23, 2008, at 9:47 AM, Martin Vales wrote:
>>
>> - CAPI GetPointAt always the same pointer:
> 
> Mateusz,
> 
> This makes sense right?  &(reader->GetPoint()) is going to get the 
> address of the reader's current point?


Hobu, Martin,

Yes, it's correct.
LASReader::GetPoint returns reference to const point object - a cache 
for point data record which is filled by LASReader::ReadPoint() function.

LASReader uses cache intentionally, to avoid allocation of new point 
object for every point data record (in every iteration).
Such allocation would significantly slow down reading opration.

If user wants to rely on point address (compare points using address or 
something), then she needs to make a copy (compare the example below 
with CPPTutorial on the Wiki):

LASReader reader(...);
while (reader.ReadNextPoint())
{
    liblas::LASPoint my_copy(reader.GetPoint());

    // now, my_copy is different from LASReader::m_point data member
}

I believe that using cached point is a compromise between memory 
management and performance. It doesn't prevent users from making their 
own copy of point object.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org



More information about the Liblas-devel mailing list