centroid - re-implement avoiding inefficient remove_empty
This commit is contained in:
parent
033c54617c
commit
01e962d216
1 changed files with 17 additions and 5 deletions
|
@ -105,17 +105,29 @@ private:
|
|||
}
|
||||
|
||||
template <typename Geom>
|
||||
result_type centroid_multi(Geom const & geom) const
|
||||
result_type centroid_multi(Geom const & multi_geom) const
|
||||
{
|
||||
// https://github.com/mapnik/mapnik/issues/3169
|
||||
#if BOOST_VERSION <= 105900
|
||||
if (mapnik::geometry::has_empty(geom))
|
||||
if (mapnik::geometry::has_empty(multi_geom))
|
||||
{
|
||||
Geom stripped = mapnik::geometry::remove_empty(geom);
|
||||
return centroid_simple(stripped);
|
||||
mapnik::geometry::multi_point<T> multi_pt;
|
||||
multi_pt.reserve(multi_geom.size());
|
||||
for (auto const& geom : multi_geom)
|
||||
{
|
||||
try
|
||||
{
|
||||
point<T> c;
|
||||
boost::geometry::centroid(geom, c);
|
||||
multi_pt.push_back(std::move(c));
|
||||
|
||||
}
|
||||
catch (boost::geometry::centroid_exception const & e) {}
|
||||
}
|
||||
return centroid_simple(multi_pt);
|
||||
}
|
||||
#endif
|
||||
return centroid_simple(geom);
|
||||
return centroid_simple(multi_geom);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue