Boost logo

Geometry :

Subject: [ggl] Intersection/difference and mixed geometries
From: Bill Zissimopoulos (ggl)
Date: 2011-01-28 03:11:31


Hello, list:

In a Sep-Oct 2010 thread I asked whether it was possible to intersect mixed type geometries. On Oct 10 2010 Barend Gehrels responded:

>> I have attempted to implement this as follows:
>> // MultiPoint, MultiLinestring, MultiPolygon can be considered std::vector's
>> MultiPoint P1; MultiLinestring L1; MultiPolygon A1;
>> // preprocess geometry G1 into P1, L1, A1
>> MultiPoint P2; MultiLinestring L2; MultiPolygon A2;
>> // preprocess geometry G2 into P2, L2, A2
>> MultiPoint P; MultiLinestring L; MultiPolygon A;
>> bg::intersection(P1, P2, P);
>> bg::intersection(L1, P2, P);
>> bg::intersection(A1, P2, P);
>> bg::intersection(P1, L2, P);
>> bg::intersection(L1, L2, P);
>> bg::intersection(A1, L2, L);
>> bg::intersection(P1, A2, P);
>> bg::intersection(L1, A2, L);
>> bg::intersection(A1, A2, A);
>>
>> However only bg::intersection(A1, A2, A) compiles. Can someone plz explain?
> OK, here you have the output specified indeed. So for lines you want to
> have points indeed. That is implemented, L1, L2, P should compile as
> well now. But this gives you only one extra combination. I'll see if
> some extra can be implemented, if you want that. At least the
> intersection of (multi)linestrings within (multi)polygons delivering
> linestrings is intersecting for many, and the basic pieces are there.

I am revisiting this because my latest experiments with boost-geometry-0.8.0 show that not all interesting intersection/difference combinations are supported.

Given:
        MultiPoint MP1, MP2, MP;
        MultiLinestring ML1, ML2, ML;
        MultiPolygon MA1, MA2, MA;

The following intersection combination compiles:
        bg::intersection(MA1, MA2, MA);
However the following "interesting" intersections do not:
        bg::intersection(MP1, MA2, MP);
        bg::intersection(ML1, MA2, ML);

Likewise for difference, the following combination compiles:
        bg::difference(MA1, MA2, MA);
However the following "interesting" differences do not:
        bg::difference(MP1, MA2, MP);
        bg::difference(ML1, MA2, ML);

Any plans to get those implemented?

Bill


Geometry list run by mateusz at loskot.net