Boost logo

Geometry :

Subject: Re: [geometry] Using Boost.Geometry with a legacy class hierarchy
From: Mats Taraldsvik (mats.taraldsvik_at_[hidden])
Date: 2012-02-12 09:48:17


Hi Barend,

On 02/11/2012 07:00 PM, Barend Gehrels wrote:
> Hi Mats,
>
> On 11-2-2012 12:34, Mats Taraldsvik wrote:
>> Hi,
>>
>> I'm trying to figure out how to adapt our legacy objects to boost
>> geometry. The first goal is to be able to extract the WKT from every
>> type of object.
>>
>> (I am eventually going to use pointers, which is why I chose to adapt
>> the point similarly to the pointer-to-point example)
>>
>> I think I've managed to adapt QPoint and QLineString, because the
>> result of the program is a correct WKT. However, if there are better
>> ways of defining a boost range for this purpose, I would love to hear
>> about it. (None of my functions are named "range_value", and since
>> the documentation states "The type defined by the metafunction
>> |range_value<...>::type| must fulfill the Point Concept
>> <http://www.boost.org/doc/libs/1_48_0/libs/geometry/doc/html/geometry/reference/concepts/concept_point.html>",
>> I guess there is a better way...?)
>
> OK I see. Notice also
> ...\libs\geometry\example\with_external_libs\x06_qt_world_mapper.cpp
> and x01_qt_example.cpp in the same folder, but maybe you did already.
>
> As far as I can see this is correct. I did not compile it but you have
> done.
>
> The range_value meta-function is (AFAIK) automatically provided, as
> long as you adapt it properly to the range concept, and so to see you
> did. Maybe we should include that in the docs.
>

I see. :) Perhaps provide a link in the Boost.Geometry docs to e.g. the
example I used in the Boost.Range docs as well?

>
>>
>> The next step is to adapt the QRing class. I need to create a single
>> iterator sequence that loops all of the linestrings contained in the
>> QRing::lines directly, but -- especially since I'm not sure if the
>> boost.range part of QLineString is done correctly -- I don't know the
>> right way to do it. Could you give me any pointers?
>
> So the linestring is done correctly, and the ring gets, in general, an
> equal implementation because they are similar w.r.t. ranges etc.
>
> What I don't understand is looping over linestrings contain in
> QRing::lines. But maybe I don't understand QRing::lines well.
> Basically Boost.Geometry's ring is a vector of points, which happen to
> form a closed polygon (without holes). So it is similar to a linestring.

You are correct -- my legacy class hierarchy is laid out to maintain the
topology/shared geometry, which does not fit seamlessly into the
Boost.Geometry model. (You might recall discussion on this list a while
back.) Therefore, I will need to create an iterator that loops over
every linestring (and the linestring's points) in QRing::lines, that
masks as a single collection of points. Do you know how (and if) I could
achieve that somehow?

> Regards, Barend
>
>
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/geometry

Regards,
Mats



Geometry list run by mateusz at loskot.net