
Geometry : 
Subject: [ggl] intersection() and mixed geometries
From: Bill Zissimopoulos (ggl)
Date: 20100927 19:28:48
Is intersection() able to intersect any two geometries together? For example, can I intersect a multipoint with a multilinestring?
Boost.Geometry does not understand the concept of mixedgeometry. However it understands the concept of multigeometry of a single type (e.g. multipoint). 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: multipoint set, L: multilinestring set, A: multipolygon 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