diff --git a/modules/core/src/main/java/org/locationtech/jts/operation/overlayng/OverlayEdge.java b/modules/core/src/main/java/org/locationtech/jts/operation/overlayng/OverlayEdge.java index 972ffd9f08..eb932fba40 100644 --- a/modules/core/src/main/java/org/locationtech/jts/operation/overlayng/OverlayEdge.java +++ b/modules/core/src/main/java/org/locationtech/jts/operation/overlayng/OverlayEdge.java @@ -147,7 +147,7 @@ public Coordinate[] getCoordinatesOriented() { */ public void addCoordinates(CoordinateList coords) { - boolean isFirstEdge = coords.size() > 0; + boolean isFirstEdge = coords.isEmpty(); if (direction) { int startIndex = 1; if (isFirstEdge) startIndex = 0; diff --git a/modules/core/src/test/java/org/locationtech/jts/operation/overlayng/OverlayNGTest.java b/modules/core/src/test/java/org/locationtech/jts/operation/overlayng/OverlayNGTest.java index adc1686fbf..934588b4c4 100644 --- a/modules/core/src/test/java/org/locationtech/jts/operation/overlayng/OverlayNGTest.java +++ b/modules/core/src/test/java/org/locationtech/jts/operation/overlayng/OverlayNGTest.java @@ -489,6 +489,15 @@ public void testPolygonLineHorizontalIntersection() { Geometry actual = intersection(a, b); checkEqual(expected, actual); } - + + /** + * Tests that overlay produces stable (non-rotated) results. + * See https://github.com/locationtech/jts/issues/865 + */ + public void testRingsNonRotated() { + Geometry a = read("POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))"); + Geometry actual = intersection(a, a); + checkEqualExact(a, actual); + } }