From 9c6352f822e7fbad7b6f50755a01ccbb82099571 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Wed, 12 Jun 2024 15:53:41 -0400 Subject: [PATCH 1/3] Debug empty multipolygon creation --- src/methods/clipping/difference.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/methods/clipping/difference.jl b/src/methods/clipping/difference.jl index 246ee55a7..dc3bf45b8 100644 --- a/src/methods/clipping/difference.jl +++ b/src/methods/clipping/difference.jl @@ -162,6 +162,7 @@ function _difference( local polys for (i, poly_b) in enumerate(GI.getpolygon(multipoly_b)) polys = difference(i == 1 ? multipoly_a : GI.MultiPolygon(polys), poly_b; target, fix_multipoly) + isempty(polys) && break end return polys end From bec910733a204b3ec82ade203d50171be8981f34 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Wed, 12 Jun 2024 16:53:26 -0400 Subject: [PATCH 2/3] Bump patch version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 60f3c1234..305d237d7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GeometryOps" uuid = "3251bfac-6a57-4b6d-aa61-ac1fef2975ab" authors = ["Anshul Singhvi and contributors"] -version = "0.1.7" +version = "0.1.8" [deps] CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298" From f70d0ca7705ca91ebdafe45c58858cb0160f4305 Mon Sep 17 00:00:00 2001 From: Skylar Gering Date: Thu, 13 Jun 2024 09:22:13 -0400 Subject: [PATCH 3/3] Add comments to multipolygon differece code --- src/methods/clipping/difference.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/methods/clipping/difference.jl b/src/methods/clipping/difference.jl index dc3bf45b8..604e4606b 100644 --- a/src/methods/clipping/difference.jl +++ b/src/methods/clipping/difference.jl @@ -161,7 +161,16 @@ function _difference( end local polys for (i, poly_b) in enumerate(GI.getpolygon(multipoly_b)) - polys = difference(i == 1 ? multipoly_a : GI.MultiPolygon(polys), poly_b; target, fix_multipoly) + #= Removing intersections of `multipoly_a`` with pieces of `multipoly_b`` - as + pieces of `multipolygon_a`` are removed, continue to take difference with new shape + `polys` =# + polys = if i == 1 + difference(multipoly_a, poly_b; target, fix_multipoly) + else + difference(GI.MultiPolygon(polys), poly_b; target, fix_multipoly) + end + #= One multipoly_a has been completly covered (and thus removed) there is no need to + continue taking the difference =# isempty(polys) && break end return polys