[Liblas-devel] Re: FOSS4G Presentation

Mateusz Loskot mateusz at loskot.net
Tue Sep 23 12:29:48 EDT 2008


Martin Rodriguez wrote:
> Hi:
> 
> 
>>> Events/delegates are different abstraction for different purposes.
>>> I don't really understand why they would be better here.
> 
> In DXFlib you can add an event to the entities you want support.
> If you want have support to points and circles for example you only add that
> events to the application.
> I use DXFlib in an application in my company to only support polyline,
> 3dpolyline, text and points.
> When dxflib read a DXF you catch that events.

It looks like "event" is a fancy name to similar concept as iterator.
Iterator is a name of general concept implementing access to elements of 
a sequence.

Now, iterators can have different faces:
- they can work just as pointers do
- they can work as a view concept - view as interms of SQL view
- they can extend elements accesssing with custom logic like filtering, 
transformation, etc.

In other words, using iterators, I can do the same what you're 
describing DXFlib does: an iterator filtering elements according to 
geometry type.

Another example could be to use iterators to implement spatial queries 
with use of spatial index, some pseudo-code:

reader = ... // reader is just a sequence of features
range = [1, 1, 10, 10] // coordinates lookup range, a bbox

spatial_query_iterator it(reader, range);
spatial_query_iterator end();

// execute spatial query - iterate through elements in given bbox
while (it != end)
{
    point = *it;
    //...
    ++it;
}

Iterators are powerful and easy to expand concept. There are some 
libraries that extend the C++ Standard Library primitives,
in compatible way:

http://www.zib.de/weiser/vtl/


The use case of events in DXFlib looks similar for me, perhaps its 
author likes events much. In some languages like Java and C#, where 
events/delegates are elements of language specification, they are more 
popular. In C++, iterators are more popular. I don't see many technical 
differences, pros nor cons.


> In liblas we only have points, but we can add differents threads in the same
> application.
> I think the natural way is use events, but I am not sure if appropriate to
> this case because we know the number of points from the beginning in lidar
> data.

When working with iterators, you don't need to know number elements you 
are going to read. You just work with ranges of elements of a sequence.


> http://www.boost.org/doc/libs/1_36_0/doc/html/foreach.html


BOOST_FOREACH is cool and it simplifies sequence iterating much.
However, it's not anything different, just a syntactic sugar to make use 
of iterators easier. But still, we need to provide access to LAS 
reader/writer with iterators, iterators in terms of STL concept.


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



More information about the Liblas-devel mailing list