|
Geometry : |
Subject: [geometry] Building difference between and MultiPolygon or Collection and Polygon
From: Stadin, Benjamin (Benjamin.Stadin_at_[hidden])
Date: 2017-04-19 15:33:40
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
Geometry list run by mateusz at loskot.net