Skip to content

Commit 26d124a

Browse files
committed
OverlayEdge: Don't skip first point when adding coordinates
Signed-off-by: Dan Baston <dbaston@gmail.com>
1 parent 123a182 commit 26d124a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

modules/core/src/main/java/org/locationtech/jts/operation/overlayng/OverlayEdge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public Coordinate[] getCoordinatesOriented() {
147147
*/
148148
public void addCoordinates(CoordinateList coords)
149149
{
150-
boolean isFirstEdge = coords.size() > 0;
150+
boolean isFirstEdge = coords.isEmpty();
151151
if (direction) {
152152
int startIndex = 1;
153153
if (isFirstEdge) startIndex = 0;

modules/core/src/test/java/org/locationtech/jts/operation/overlayng/OverlayNGTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ public void testPolygonLineHorizontalIntersection() {
489489
Geometry actual = intersection(a, b);
490490
checkEqual(expected, actual);
491491
}
492-
492+
493+
/**
494+
* Tests that overlay produces stable (non-rotated) results.
495+
* See https://github.com/locationtech/jts/issues/865
496+
*/
497+
public void testRingsNonRotated() {
498+
Geometry a = read("POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))");
499+
Geometry actual = intersection(a, a);
500+
checkEqualExact(a, actual);
501+
}
493502

494503
}

0 commit comments

Comments
 (0)