Boost logo

Geometry :

Subject: [ggl] Linestring with Pointers to points
From: Barend Gehrels (barend)
Date: 2011-08-19 23:36:41


Hi Bernhard,

On 18-8-2011 18:38, Bernhard wrote:
> Hi,
>
> I'm trying to figure out what is the best way to create linestrings that do
> not operate on points, but on pointers to points, because in my project
> there should be several linestrings operating on the same (physical) points,
> due to the metadata attached to the points.
>
> Obviously linestring<point *> does not work.
> Now, I could create a second pointer class that stores a pointer to the real
> point class and wraps the functions and register that class with boost
> geometry, but that seems like really bad design to me (or is there some
> template magic that does something like that automatically?)
>
> Is what I am trying to achieve not possible, a bad design idea, or am I
> missing something completely?
>

It should be possible. But there are some restrictions.

The best place to look at is the c05 example, e.g. here:
<http://svn.boost.org/svn/boost/trunk/libs/geometry/example/c05_custom_point_pointer_example.cpp>

It defines a linestring with pointers to points, so just as you ask for.
There are no (at least not yet) macro's to register such points, so
adaption to traits classes is a manual process. It does not wrap a
class, but registers the pointer-to-point class directly using
specialization on the pointer.

The restrictions are that these types are readonly. Because how would an
intersection create new points... That probably could be solved somehow,
but currently geometries with pointer-to-points can be used as readonly
geometries.

It is not tested as extensively as other types are, so please notice if
anything does not work as expected.

Regards, Barend


Geometry list run by mateusz at loskot.net