Boost logo

Geometry :

Subject: Re: [geometry] Using Boost.Geometry with a legacy class hierarchy
From: Barend Gehrels (barend_at_[hidden])
Date: 2012-02-19 17:05:15

Hi Mats,

Herewith another and better solution on your question

On 19-2-2012 22:41, Barend Gehrels wrote:
> Hi Mats,
> On 17-2-2012 12:10, Mats Taraldsvik wrote:
>> Hi,
>> With the help of boost::iterator_facade and [1],
>> I've almost managed to adapt the Ring concept to my legacy objects,
>> but I got a compile time error which I don't understand. As you can
>> see from the code, the iterator exposes QPoint* objects directly, so
>> that should work properly.
>> The cpp files and the errors from the build log is here [2].
>> [1]
>> [2]
>> Regards,
>> Mats Taraldsvik

If you achieve to not use the pointer-versions but just the normal
versions, everything becomes a lot easier. You can then still use the
pointer-versions in your ring. But you add the QPoint version to the traits.

This is not that difficult.

The iterator implementation then needs only a small difference:

         R dereference() const {return
(we deference it here)

and the typedefs:
     typedef RingIteratorImpl<std::vector<QLineString*>::iterator,
QPoint> RingIterator;
     typedef RingIteratorImpl<std::vector<QLineString*>::const_iterator,
const QPoint>

So we basically consider it as iterating over QPoint& and not over QPoint*

I did not check the iterator_base there might be other (better)
solutions for this as well, but this basically works at least.

Having done this, the wkt streaming works (without any change to
Boost.Geometry). And besides this you can expect a lot less problems
because you handle a point as a point and not as a pointer.

If you do the same for linestring you can remove the pointer version to
the traits (did not do that).

My adaptions are here:

So this does not need any change to Boost.Geometry.

Regards, Barend

Geometry list run by mateusz at