From b911464472f2394fba02ba40ddaa9fbe91b74261 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 26 Feb 2024 14:40:36 +0000 Subject: [PATCH] correct 'is_empty' implementation for multi geometries --- include/mapnik/geometry/is_empty.hpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/include/mapnik/geometry/is_empty.hpp b/include/mapnik/geometry/is_empty.hpp index fccf7eae0..e39a5b9f7 100644 --- a/include/mapnik/geometry/is_empty.hpp +++ b/include/mapnik/geometry/is_empty.hpp @@ -39,18 +39,36 @@ struct geometry_is_empty bool operator()(mapnik::geometry::point const&) const { return false; } - bool operator()(mapnik::geometry::line_string const& geom) const { return geom.empty(); } + bool operator()(mapnik::geometry::line_string const& line) const { return line.empty(); } - bool operator()(mapnik::geometry::polygon const& geom) const + bool operator()(mapnik::geometry::polygon const& poly) const { - return geom.empty() || geom.front().empty(); + for (auto const& ring : poly) + { + if (!ring.empty()) return false; + } + return true; } bool operator()(mapnik::geometry::multi_point const& geom) const { return geom.empty(); } - bool operator()(mapnik::geometry::multi_line_string const& geom) const { return geom.empty(); } + bool operator()(mapnik::geometry::multi_line_string const& mline) const + { + for (auto const& line : mline) + { + if (!line.empty()) return false; + } + return true; + } - bool operator()(mapnik::geometry::multi_polygon const& geom) const { return geom.empty(); } + bool operator()(mapnik::geometry::multi_polygon const& mpoly) const + { + for (auto const& poly : mpoly) + { + if (!operator()(poly)) return false; + } + return true; + } bool operator()(mapnik::geometry::geometry_collection const& geom) const { return geom.empty(); }