Boost logo

Geometry :

Subject: [ggl] intersection() and mixed geometries
From: Bill Zissimopoulos (ggl)
Date: 2010-09-27 19:28:48


Is intersection() able to intersect any two geometries together? For example, can I intersect a multi-point with a multi-linestring?

Boost.Geometry does not understand the concept of mixed-geometry. However it understands the concept of multi-geometry of a single type (e.g. multi-point). I thought that it should be easy then to emulate mixed geometry set operations using simple set algebra:
        Let u: union, n: intersection, 0: empty set
        Let P: multi-point set, L: multi-linestring set, A: multi-polygon set

Any mixed geometry G can be written
        G = P u L u A

Given two mixed geometries
        G1 = P1 u L1 u A1
        G2 = P2 u L2 u A2
we have for their intersection:
        G1 n G2 = G1 n (P2 u L2 u A2)
                = (P1 n P2) u
                  (L1 n P2) u
                  (A1 n P2) u
                  (P1 n L2) u
                  (L1 n L2) u
                  (A1 n L2) u
                  (P1 n A2) u
                  (L1 n A2) u
                  (A1 n A2)

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?

Bill


Geometry list run by mateusz at loskot.net