Hi,

I want to cut out all smaller polygons which are within one larger polygon. I used GEOS for this, but due to performance issue with GEOS to build the difference I wanted to give BOOST a try. To give an example, the following
works with GEOS. But it seems it needs to be worked around in BOOST Geometry, since the difference method doesn’t take a vector or geometry collection.

Example code using GEOS:

const geos::geom::Geometry* cutGeometry = originalGeometry->clone();

for (auto intersectIndexValue : intersects)

{

const geos::geom::Geometry *intersectCandidate = intersectIndexValue.second->geom();

if (intersectCandidate->within(originalGeometry))

{

cutGeometry = cutGeometry->difference(intersectCandidate);

}

}

double originalAreaSize = originalGeometry->getArea();

double cutAreaSize = cutGeometry->getArea();

// … do something if the cutted polygon is too small compared to the original

So the issue is that boost::geometry::difference() takes a single input geometry, a single geometry to build the difference against, and an output vector for the cut resulting geometry / geometries. But it doesn’t take
a collection as input.

Is there an alternative and efficient way to build the difference between using input polygon collection instead of just a single polygon?

Regards

Ben