I have to union many boost::polgons, but my approach does not seem very performant (>15 min), especially with larger numbers of polygons (>2000).
I push all the polygons i want to union into a multipolygon and then join the multipolygon, see my code:
BOOST_FOREACH(polygon, multipolygon)
{
boost::geometry::clear(tmp_union); //tmp_union is a multipolygon
boost::geometry::union_(result, poly, tmp_union);
result = tmp_union;
}
The result will presumably not contain very many polygons, because most of the polygons to union will intersect.
Is there any way to make this more performant, like sorting the polygons in some specific order or a completely different approach?