From ab2a5b47589ce53a690d2835749475bbb50ce967 Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Mon, 21 Jun 2021 17:53:11 -0700 Subject: [PATCH] All TestBuilder PolygonOverlayFunctions to support linear inputs Signed-off-by: Martin Davis --- .../jtstest/function/PolygonOverlayFunctions.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/app/src/main/java/org/locationtech/jtstest/function/PolygonOverlayFunctions.java b/modules/app/src/main/java/org/locationtech/jtstest/function/PolygonOverlayFunctions.java index 2cbdcfe070..c62a3ca23e 100644 --- a/modules/app/src/main/java/org/locationtech/jtstest/function/PolygonOverlayFunctions.java +++ b/modules/app/src/main/java/org/locationtech/jtstest/function/PolygonOverlayFunctions.java @@ -93,8 +93,17 @@ private static Geometry computeOverlay(Geometry g1, Geometry g2, Noder noder) polygonizer.add(nodedDedupedLinework); List resultants = (List) polygonizer.getPolygons(); - // use PIP to find polygons which have a parent - List polys = ParentFinder.findParents(g1, g2, resultants); + /** + * If the input contained polygons, + * use PIP to find polygons which have a parent. + * Otherwise just return all resultants + * (to support providing just lines as input) + */ + boolean hasPolys = g1.getDimension() >= 2; + List polys = resultants; + if (hasPolys) { + polys = ParentFinder.findParents(g1, g2, resultants); + } // convert to collection for return Polygon[] polyArray = GeometryFactory.toPolygonArray(polys);