Building difference between and MultiPolygon or Collection and Polygon

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Building difference between and MultiPolygon or Collection and Polygon

Stadin, Benjamin via Geometry

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 mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/geometry
Loading...